O'Reilly logo
live online training icon Live Online training

Introduction to Modularity with the Java 9 Platform Module System (JPMS)

An overview of Java’s most important new software-engineering technology since its inception 20+ years ago

Paul J. Deitel

In this full-day Java 9: Modularity Live Online Training, Paul Deitel introduces the Java Platform Module System (JPMS)—Java 9’s most important new software-engineering technology. Modularity—the result of Project Jigsaw—helps developers at all levels be more productive as they build, maintain and evolve software systems, especially large systems.

Modularity adds a higher level of aggregation above packages. The key new language element is the module—a uniquely named, reusable group of related packages, resources (like images and XML files) and a module descriptor specifying:

  • the module’s name
  • the module’s dependencies (that is, other modules this module depends on)
  • the packages it explicitly makes available to other modules (all other packages in the module are implicitly unavailable to other modules)
  • the services it offers
  • the services it consumes, and
  • to what other modules it allows reflection.

According to JSR 376: Java Platform Module System, the key goals of modularizing the Java SE Platform include: reliable configuration, strong encapsulation, scalable Java Platform, greater platform integrity, and improved performance.

What you'll learn-and how you can apply it

In this live online training, you will:

  • 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 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 the uses and provides...with directives, 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 that 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.

This training course is for you because...

  • You’re a Java developer interested in the upcoming Java 9.
  • You need to migrate legacy code into modularized Java 9.
  • You want to familiarize yourself with the Java Platform Module System’s capabilities and migration mechanisms.

Prerequisites

SETUP REQUIRED PRIOR TO THE FIRST COURSE MEETING:

Before taking this course, if you want to do the demonstrations and participate in labs, you must install the latest JDK 9 Developer Preview, the course’s source-code examples and the NetBeans IDE with early access JDK 9 support. We use the NetBeans IDE’s modularity support and tools to create module graphs and to show a project’s modular structure. IDEs like IntelliJ and Eclipse also have some early access JDK 9 support and will likely provide more in the future.

Setup/Install Video Tutorials

Installing JDK 9 Developer Preview on Windows

Installing JDK 9 Developer Preview on macOS

We also provide Getting Started videos discussing these downloads and the installation steps at http://www.deitel.com/books/Java9FP. These videos contain Paul Deitel’s contact information, please feel free to contact Paul before the course if you have any questions about the course content and/or setup.

About your instructor

  • Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of MIT with 35 years of experience in computing. He is an Oracle Java Champion. He and his co-author, Dr. Harvey M. Deitel, are the world’s best-selling programming-language textbook/professional book/video/e-learning authors. Paul is one of the world’s most experienced Java trainers—he has delivered Java, Android, iOS, C#, C++, C and Internet programming courses to industry clients internationally, including Cisco, IBM, Sun (now Oracle), Dell, Siemens, Lucent, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, White Sands Missile Range, Rogue Wave Software, Boeing, SunGard Higher Education, Stratus, Cambridge Technology Partners, Entergy, CableData Systems, Nortel Networks, Puma, iRobot and many more.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Segment 1 Introduction

Segment 2 Module Declarations

  • 2.1 requires
  • 2.2 requires transitive—Implied Readability
  • 2.3 exports and exports…to
  • 2.4 uses
  • 2.5 provides…with
  • 2.6 open, opens and opens…to
  • 2.7 Restricted Keywords

Segment 3 Modularized Welcome App

  • 3.1 Welcome App’s Structure
  • 3.2 Class Welcome
  • 3.3 module-info.java
  • 3.4 Module-Dependency Graph
  • 3.5 Compiling a Module
  • 3.6 Running an App from a Module’s Exploded Folders
  • 3.7 Packaging a Module into a Modular JAR File
  • 3.8 Running the Welcome App from a Modular JAR File
  • 3.9 Aside: Classpath vs. Module Path

Segment 4 Creating and Using a Custom Module

  • 4.1 Exporting a Package for Use in Other Modules
  • 4.2 Using a Class from a Package in Another Module
  • 4.3 Compiling and Running the Example
  • 4.4 Packaging the App into Modular JAR Files
  • 4.5 Strong Encapsulation and Accessibility

Segment 5 Module-Dependency Graphs: A Deeper Look

  • 5.1 java.sql
  • 5.2 java.se
  • 5.3 Browsing the JDK Module Graph
  • 5.4 Error: Module Graph with a Cycle

LUNCH BREAK (1 hour)

Segment 6 Migrating Code to Java 9

  • 6.1 Unnamed Module
  • 6.2 Automatic Modules
  • 6.3 jdeps: Java Dependency Analysis

Segment 7 Resources in Modules; Using an Automatic Module

  • 7.1 Automatic Modules
  • 7.2 Requiring Multiple Modules
  • 7.3 Opening a Module for Reflection
  • 7.4 Module-Dependency Graph
  • 7.5 Compiling the Module
  • 7.6 Running a Modularized App

Segment 8 Creating Custom Runtimes with jlink

  • 8.1 Listing the JRE’s Modules
  • 8.2 Custom Runtime Containing Only java.base
  • 8.3 Creating a Custom Runtime for the Welcome App
  • 8.4 Executing the Welcome App Using a Custom Runtime
  • 8.5 Using the Module Resolver on a Custom Runtime

Segment 9 Services and ServiceLoader

  • 9.1 Service-Provider Interface
  • 9.2 Loading and Consuming Service Providers
  • 9.3 uses Module Directive and Service Consumers
  • 9.4 Running the App with No Service Providers
  • 9.5 Implementing a Service Provider
  • 9.6 provides…with Module Directive and Declaring a Service Provider
  • 9.7 Running the App with One Service Provider
  • 9.8 Implementing a Second Service Provider
  • 9.9 Running the App with Two Service Providers