Paul Deitel
Paul Deitel

Paul Deitel, CEO of Deitel & Associates, Inc., co-author of Java® 9 for Programmers, and an Oracle Java Champion, is leading a live online introduction to the Java Platform Module System (JPMS).

Deitel’s two-day live online training will be presented only on Safari, O’Reilly’s learning platform.

Modularity—the result of Project Jigsaw—benefits developers at all levels by helping them manage and reduce complexity, leading to increased productivity in the construction, maintenance, and evolution of software systems—especially large-scale software systems.

What you’ll learn in Introduction to Modularity with the Java® 9 Platform Module System

In this live online training, you’ll:

  • Understand the motivation for modularity.
  • Review key JPMS requirements.
  • Modularize pre-Java-9 code, then execute the modularized version.
  • Create module declarations that specify module dependencies with requires, and specify the packages a module makes available to other modules with exports.
  • Selectively allow runtime reflection of types with open and opens.
  • Use services to loosely couple system components, making large-scale systems easier to develop and maintain.
  • Indicate that a module explicitly uses a service or provides a service implementation with uses and provides...with, respectively.
  • Use the jdeps command to determine a module’s dependencies.
  • Understand how unnamed and automatic modules enable you to continue using non-modularized pre-Java-9 code in Java 9.
  • Use the NetBeans IDE to create module graphs to visualize the modular JDK as well as your own modular systems.
  • See the module resolver in action as it determines runtime dependencies.
  • Use jlink to create smaller runtimes appropriate for resource-constrained devices—for example, Internet of Things (IoT) devices.
  • And more.

Visit Safari for the detailed course outline and prerequisites for Introduction to Modularity with the Java® 9 Platform Module System.

How Java 9 modularity will make developers’ lives easier

According to JSR 376: Java Platform Module System, the key goals of modularizing the Java SE Platform are:

Reliable configuration—You must explicitly declare dependencies between modules in a manner that’s recognized both at compile time and execution time. The system can automatically walk through these dependencies (via the module resolver) to determine the subset of all modules required to support your app.

Strong encapsulation—The packages in a module are accessible to other modules only if the module explicitly “exports” them (that exporting can be restricted to select modules). Even then, another module cannot use those packages unless it explicitly states that it “requires” the other module’s capabilities.

Scalable Java Platform—Previously, the Java Platform was a monolith consisting of a massive number of packages, making it challenging to develop, maintain, and evolve. It couldn’t easily be subsetted. The platform is now modularized into 95 modules. You can create custom runtimes consisting of only the modules you need for your apps or the devices you’re targeting. For example, if a device does not support GUIs, you could create a runtime that does not include the GUI modules, significantly reducing the runtime’s size.

Greater platform integrity—Before Java 9, it was possible for application and library developers to use internal APIs in the platform that were not intended for such use. With strong encapsulation, these internal APIs can be truly hidden. This can be problematic when migrating code to Java 9—this issue is being dealt with via deprecation and new comparable public APIs.

Improved performance—The JVM uses various optimization techniques to improve application performance. JSR 376 indicates that these techniques are more effective when it’s known in advance that required types are located only in specific modules.

Other benefits of modularity include:

Eliminating "classpath hell"—Prior to modularity, developers used the classpath to specify libraries for use at compilation and execution time. Most developers have experienced classpath problems, some to the extent that the term “classpath hell” was coined to describe them. With modularity, developers switch from using the classpath to using the module path, which eliminates the vast majority of classpath-related problems.

Better system designs—You may find that modularity helps you come up with cleaner, more logical designs.

About O'Reilly's live online training

Since launching live online training courses in December, 2016, O'Reilly has trained over 14,000 people in more than 150 courses, including Docker: Up and Running, Designing for Voice: Conversational UI, Python: Beyond the Basics, High-Performance TensorFlow in Production, and Design Thinking: Practice and Measurement Essentials.

Article image: Paul Deitel