concept module path in category java

appears as: module path, The module path, module path
The Java Module System

This is an excerpt from Manning's book The Java Module System.

The first one, java.base, is already known, so the module system can add a connection from my.xml.app to java.base —the first edge in the graph. Next up is java.xml. It begins with java, which tells the module system it’s a platform module; so the JPMS doesn’t search the module path for it, but instead searches its own module storage. The JPMS finds java.xml there and adds it to the graph with a connection from my.xml.app to it.

  • An automatic module is created by the module system for each plain JAR it finds on the module path. (Section 8.3 is dedicated to this concept.)
  • The class path makes no distinction between plain and modular JARs: if it’s on the class path, it ends up in the unnamed module. Similarly, the module path makes little distinction between plain and modular JARs: if it’s on the module path, it ends up as its own named module. (For plain JARs, the module system creates an automatic module; for modular JARs, it creates an explicit module according to the description.)

    To understand the rest of this chapter as well as to perform a modularization, it’s important to fully internalize that behavior. Table 8.1 shows a two-dimensional recast. Not the type of JAR (plain or modular) but the path it’s placed on (class path or module path) determines whether it becomes part of the unnamed module or a named module.

    Table 8.1 It isn’t the type of the JAR but the path it’s placed on that determines whether a class ends up as a named module or in the unnamed module. (view table figure)
    Class path Module path
    Plain JAR Unnamed module (section 8.2) Automatic module (section 8.3)
    Modular JAR Explicit module (section 3.1.4)

    When deciding whether to place a JAR on the class path or the module path, it’s not about where the code comes from (is the JAR modular?); it’s about where you need the code to be (in the unnamed or a named module). The class path is for code you want to go into the ball of mud, and the module path is for code you want to be a module.

    Figure 8.6 With the plain JARs monitor.jar, monitor.observer.jar, and monitor.statistics.jar on the module path, the JPMS creates three automatic modules for them. The class-path content ends up in the unnamed module as before. Note how automatic modules read each other and the unnamed module, creating lots of cycles in the graph.

    c08_06.png