Category: Goals of the Modular JDK

  • Automatic Modules – Java Module System

    Automatic Modules A plain JAR—that is, a JAR that does not have a module-info.class file in its top-level directory—defines an automatic module when placed on the module path. An automatic module has a module name which is determined according to the scheme described below. An automatic module can read all…

  • Explicit Modules – Java Module System

    Explicit Modules As the name implies, an explicit module is described by its module descriptor that explicitly specifies its name and the modules it reads (i.e., its dependencies), including any packages it exports or opens, or any services it provides or uses. A modular JAR is treated as an explicit…

  • Exploring Modules – Java Module System

    19.13 Exploring Modules This section provides an introduction to using the JDK tools to discover, explore, and analyze modular applications. Given the JARs main.jar, control.jar, view.jar, and model.jar for the adviceApp application in the mlib directory in Figure 19.14(c), p. 1188, we will use JDK tools to explore these archives…

  • Module Basics – Java Module System

    19.3 Module Basics Underlying the Java Module System is the concept of a module which is defined in the language and supported by the various JDK tools (such as javac, java, jar, and jdeps) and the Java runtime environment. An understanding of packages is a prerequisite for understanding modules. The…

  • Qualified Export – Java Module System

    Qualified Export Any package that is exported by a module is readable by any module that requires its module. However, sometimes it is necessary that only certain modules can access an exported package. This can be achieved by using the exports-to directive, as shown below at (1), where packageOne in…

  • Better Performance – Java Module System

    Better Performance Modules in Java contribute to developing scalable systems with improved performance, as modules can be optimized independently. The module system guarantees that all classes of the same package are in the same module—that is, there are no split packages, and the modules describe explicit dependencies. The class loader…

  • Compiling and Running a Modular Application – Java Module System

    19.6 Compiling and Running a Modular Application Both the javac tool to compile Java source code and the java tool to launch an application include new command-line options to specifically support building of modular applications. When the javac tool or the java tool is called, initially a module resolution is…

  • Multi-Module Compilation – Java Module System

    Multi-Module Compilation It is tedious compiling modules individually. It is more convenient to use the following command: Click here to view code image >javac –module-source-path src -d mods –module main The –module-source-path option (no short form), as the name suggests, indicates the src directory where the exploded modules with the…

  • Creating JAR Files – Java Module System

    19.7 Creating JAR Files A JAR (Java Archive) file is a convenient way of bundling and deploying Java executable code and any other resources that are required (e.g., image or audio files). A JAR file is created by using the jar tool. The jar command has many options, akin to…

  • Qualified Opens Directive – Java Module System

    Qualified Opens Directive Sometimes it is necessary that only certain modules can access an open package for reflection. This can be achieved by using the opens-to directive, as shown below at (1), where package org.liberal.sesame in module org.liberal is only open to modules com.aladdin and forty.thieves. This is known as…