The Java Platform Module System

The Java Platform Module System

Although Java 9 is not the latest JDK release (to be more specific, it was released back in 2017), it was the biggest update in the history of the JDK. Despite that, most Java programmers hardly mention its most significant feature — the Java Platform Module System.

Although Java 9 is not the latest JDK release (to be more specific, it was released back in 2017), it was the biggest update in the history of the JDK. Despite that, most Java programmers hardly mention its most significant feature — the Java Platform Module System.

This is primarily because most business applications still use Java 8. For now, it has demonstrated stability and newer releases need time to spread across the IT world.

That’s why I decided to write this article. In the future, if you facing this technology, you will be able to get a flying start.

Java 9: A Historical Perspective

  • 2006: Java 6 by Sun Microsystems (compare to previous releases it was fairly minor)
  • 2011: Java 7 was the first Oracle release; it contained far fewer features than anticipated. Mainly low-level API changes.
  • 2014: Java 8: Serious innovations, specifically lamdas and streams.
  • 2017: The Java 9 release was postponed several times due to setbacks regarding the module system implementation. But finally, in September 2017, it was released.

Since Java 9, there has been a new release every six months. Before that, there was only one release once the planned features were complete.

The Java Platform Module System

One of the biggest changes in Java, ever.

It affects the followings:

  • **Language **(new features and keywords)
  • **Compiler **(needs to translate new features and must know module boundaries)
  • **JVM **(All module metadata around modules are preserved in a binary format and loaded by the JVM)
  • **Tooling **(IDEs, libraries need to adapt to modularity)

Reasons Why the Module System Added to the Language

There are a few reasons why modularizing was necessary.

Modularize the JDK Itself

The Java JDK is over 20 years old, and it was one big file. It was hardly maintainable. Everything was chained together and they would like to work down this technical debt to make it maintainable again.

Modularize Applications

Along with the modularized JDK, developers should modularize their applications as well. Although, it is important to note that modularization is optional!

If you switch to Java 9, you can keep using Java as you used to, or you can switch to the module system and start to modularize your application and make it more maintainable.

Although you will still run on modularized JDK, this can still affect your code!

Before the Modular JDK

  • One huge library: rt.jar (runtime.jar)
  • This library was only grown and nothing removed from it in the last 20 years.
  • Many inner libraries have been used by outer applications even that they do not suppose to do that, but there was no way to restrict that.

The Modular JDK: Explicit Dependencies

This is how the new Java platform looks like.

They divided JDK into more than 90 separate modules. Each module encapsulates its own piece of functionality of the Java runtime library. The picture above represents the dependencies between the modules.

The most important one is the *java.base *module. It represents the most basic classes of the language, like streams, strings, and objects. Since this module is essential, all other modules depend on this library.

Here, we see a more complex graph about the different libraries and how they connect to each other. The ones with names starting with *java *indicate that these are part of the Java SE specifications.

In the dependency graph above, you can also see two modules in blue; these do not start with java but jdk. These are JDK-specific.

You may notice that all arrows are pointing down. This means that there are no circular dependencies. Hence, it has very clean modularization.

Let’s see some examples:

*Corba *is ancient technology, and it's still part of the JDK. However, it is isolated into its module. This means that unless your application has a dependency on java.corba, this old technology won’t get in.

Another module in this graph you may be more familiar: Java.desktop. It contains all the swing GUI toolkits of the Java platform. Hence, your application doesn’t need any of these GUI dependencies; and you do not need to reference the java.desktop module.

The Modular JDK Advantages

Increased Security

That’s a one we didn’t touch upon yet. This is due that the fact a module can explicitly expose some of the packages and strongly encapsulate other packages. As I mentioned earlier, there are many internal implementations in classes in the JDK that need to be public because it is used among different packages, but at the same time, they should not be used outside of JDK. These later ones are encapsulated.

Reduced Footprint

If you start, make modularized applications on top of the Modularized JDK. You do not need to scan and load all the classes that the *rt.jar *contains, which you cannot avoid before you can only include the necessary modules.

Easy Deprecation

Having clearly separate modules also helps deprecation. The idea is that, at some point, a module can be marked as deprecated. Every application that uses that module should look to another solution. After that, in the next major release, it can be removed from the JDK.

It is already happening because in Java 9, the *java.corba *module has been marked as deprecated.

Future Proof

The deprecation example is true from the other way as well. It is much easier to ship new features to the language. They can add incubator modules, and if it is stable, it can be converted to a real module with the next major release.

There is an example as well as the *jdk.incubator.httpclient *module.

What Is a Module?

Now, we see the new modularized JDK, but a big question remains: What exactly is a module?

A module has a name; it has a distinct identity; it has **groups **related code. Furthermore, it fully self-contained, which means that it needs to contain everything to do its functions. If it hasn’t, it must reference another module from the library.

Module Descriptors

The below image shows how a module builds up.

This structure is described in the module-info.java.

module java.base {
  exports java.lang;
  exports java.util;
  exports java.io;
  //etc.
}

We do not see any external module dependencies here because *java.base *do not reference any.

Let us see another example.

The *java.sql *references to two other modules, these are marked in our descriptor.

As you may have noticed, we have three new keywords in this context.

  • module
  • exports
  • requires

These keywords are live in the context of the module, so you do not need to be aware of them in your application code.

If you have Java 9 > installed, you can list out all modules that are currently in the JDK by the *java –list-modules *keyword typed in your operating system console.

Another good function is that you can get a definition overview of every module independently with the *java –describe-module *keyword.

Summary

Hope you enjoyed my article. Here, I described the Java Platform Module System and what Java 9 brought to the language. This was the most major update to the JDK in the last 20 years.

In my upcoming articles, I would like to mention some other features of Java 9 and also introduce the most recent versions of the JDK —10, 11, and 12.

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Description
This is the best course to learn to program in Java in Spanish from scratch and without any experience in this fabulous programming language. This is the first course where we will study the Fundamentals of Java, and we will take you step by step until you acquire the bases of the Java language and you can start to study more advanced Java topics.

The content is divided into perfectly structured levels, each level supported by the previous one, with the aim of adding Java knowledge incrementally and so you can focus on mastering the issues little by little and gradually. So ensure the success of your Java training.

We will also offer support for any doubts about the didactic material included in this Java Fundamentals course.

We manage a new teaching methodology that we have called Speed ​​Learning. This methodology consists of concise videos that go directly to the point to be studied, complemented by eBooks with explanations and step-by-step images (which you can print, or search for any text you need, or use for your offline study), since As we know we can not do text search within a video. In addition, our methodology includes perfectly structured and very didactic exercises that will allow you to accelerate your eLearning learning. No loss of time in videos where you have to watch the instructor codify an exercise, too much theory, little practice or anything like that. Our Speed ​​Learning methodology guarantees that in the shortest possible time you will acquire the necessary knowledge for the Java professional and working world.

The Java Fundamentals course includes the following topics for study:

Lesson 1 - Starting with Java Technology

The amazing world of Java programming

What is Java technology (from a practical approach)

Our first Java program from scratch

Lesson 2 - Variables and Operators in Java

Use of Variables in Java and what we use them for

Types of Data in Java and how they are classified

Management and Classification of operators in Java

Lesson 3 - Control statements in Java

Using the if-else structure and where to use it

Handling the switch structure and when applying it

Lesson 4 - Handling Loops in Java

Use of the for loop and its use

Using the while loop and how to apply it

Use of the do-while loop and when to use it

Lesson 5 - Object Oriented Programming

Introduction to Object Oriented Programming (OOP)

Handling Classes in Java

Use of Objects in Java

Lesson 6 - Functions in Java

Declaration of Methods or Functions in Java

Use and call of functions in Java

Lesson 7 - Data Management in Java

Using Arrays in Java

Management of Matrices in Java

Lesson 8 - Inheritance in Java

Inheritance Management in Java

Use of superclasses and subclasses in Java

Final Level Laboratory

Final Exercise where everything learned in this Level is integrated

At the end you get a certificate of having completed the Java Fundamentals course.

We wait for you on the other side.

Ing. Ubaldo Acosta

Founder of Global Mentoring

Passion for Java Technology

Who this course is for:

Anyone who wants to learn how to program in Java
Basic knowledge
Basic knowledge of PC use
Basic management of an operating system such as Windows, Mac or Linux
It is not necessary to know how to program, we will start from scratch !!!
The attitude and desire to start coding and learning Java once and for all from scratch!
What will you learn
Have the basics of the programming language with Java
You will know the basic syntax of the Java language
Manage the concept of Variables and Operators in Java
We will study Object Oriented Programming with Java
You will learn the Control Statements and Loops in Java
We will see the concept of Functions with Java
We will study the concept of Inheritance in Java
We will learn to use Arrays in java
We will handle the concept of Matrices in Java
We will learn to Design Classes in Java
We will make a final application with everything learned in the course
To know more:

Java Essentials : Learn Core Java From Basic to Advance

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Description
This is only Java related course and it's great because it covers just the right amount of Java which is needed to leaning programming, java.

This is a comprehensive yet simple course on java programming language and it concentrates on Java programming concepts.

*************************** No Prior Coding Experience Needed ***************************

This course assumes that you have no programming background. If you have some experience then, it's just a bonus point. You have never code, have some experience or have a lot of experience any other programming language, this course is one stop place for you.

Java is one of the most and useful programming languages to learn You can build back-end of web applications and build robust test automation framework. Specially for Selenium WebDriver GUI automation, Java is most popular choice and has the largest community.

Each lecture consist of a video screencast and code files

There are quizzes, homework to test your knowledge

High focus on practice and asking questions

You will also learn coding best practices

Market is never short of jobs in Java programming language, there are ample of jobs in both Java development and Automation Testing using Java.

What are you waiting for? Enroll today and learn the powerful Java language !!!

Basic knowledge
Nothing else! It’s just you, your computer and your hunger to get started today
Java concepts are covered in the course, no experience needed
Windows/MAC computer
What will you learn
You will be able to EXPLAIN, DESIGN and IMPLEMENT efficient java Programs
You will be confident to clear test automation interviews
Understand the concepts of Object Oriented Programming Language
Complete understanding of java
Expert-level knowledge of Java code (+ advanced tips and tricks used by the pros)
Suitable for beginner programmers and ideal for users who learn faster when shown
To learn more:

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios

Description
This is the best course to learn to program in Java in Spanish from scratch and without any experience in this fabulous programming language . This is the first course where we will study the Java Fundamentals, and we will take you step by step until you acquire the basics of the Java language and so you can start studying more advanced Java topics.

The content is divided into perfectly structured levels , each level supported by the previous one, with the aim of adding Java knowledge incrementally so that you can focus on mastering the issues little by little and gradually. So ensure the success of your Java training.

In other offer support of any doubt teaching materials included in this course Fundamentals of Java.

To make matters worse, we handle a new teaching methodology that we have called Speed ​​Learning. This methodology consists of concise videos that go directly to the point to study, complemented with eBooks with explanations and step-by-step images (which you can print, or search for any text you need, or use for your offline study), since as we know we cannot do text search within a video. In addition, our methodology includes perfectly structured and very didactic exercises, which will allow you to accelerate your eLearning learning. Without wasting time on videos where you have to watch the instructor codify an exercise, too much theory, little practice or anything like that. Our Speed ​​Learning methodology guarantees that in the shortest possible time you will acquire the necessary knowledge for the professional and professional world of Java.

The Java Fundamentals course includes the following topics of study:

Level. Java basics

Lesson 1 - Starting with Java Technology

The amazing world of Java programming
What is Java technology (from a practical approach)
Our first Java program from scratch
Lesson 2 - Variables and Operators in Java

Use of Variables in Java and what we use them for
Data types in Java and how they are classified
Operator Management and Classification in Java
Lesson 3 - Control sentences in Java

Use of the if-else structure and where to use it
Management of the switch structure and when to apply it
Lesson 4 - Cycle Management in Java

Use of the for cycle and its use
Use of the while cycle and how to apply it
Use of the do-while cycle and when to use it
Lesson 5 - Object Oriented Programming

Introduction to Object Oriented Programming (OOP)
Class Management in Java
Using Objects in Java
Lesson 6 - Functions in Java

Declaration of Methods or Functions in Java
Use and call of functions in Java
Lesson 7 - Data Management in Java

Using Arrangements in Java
Matrix Management in Java
Lesson 8 - Inheritance in Java

Inheritance Management in Java
Use of superclasses and subclasses in Java
Final Level Laboratory

Final Exercise where everything learned in this Level is integrated
At the end you get a certificate of having completed the Java Fundamentals course.

We wait for you from the other side.

Ing. Ubaldo Acosta

Founder of Global Mentoring

Passion for Java Technology

Who this course is for:

Anyone who wants to learn to program in Java
Basic knowledge
Basic knowledge of PC use
Basic operation of an operating system such as Windows, Mac or Linux
It is not required to know how to program, we will start from scratch !!!
The attitude and desire to start coding and learning Java once and for all from scratch !!!
What will you learn
Have the basics of the programming language with Java
You will know the basic syntax of the Java language
Will handle the concept of Variables and Operators in Java
We will study Object Oriented Programming with Java
You will learn Control Sentences and Cycles in Java
We will see the concept of Functions with Java
We will study the concept of Inheritance in Java
We will learn to use Arrangements in java
We will handle the concept of Matrices in Java
We will learn to Design Classes in Java
We will make a final application with everything learned in the course
To continue: