Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspect --module-path value at runtime

Is there any way to get list of directories which are included in module-path with use of -p or --module-path arguments at runtime similar to how I whold get all classpath directories using System.getProperty("java.class.path")?

like image 469
Artem Petrov Avatar asked May 26 '18 14:05

Artem Petrov


People also ask

What is module path?

A module path is a reference to a module, as used with require or as the initial-module-path in a module form. It can be any of several forms: (quote id) A module path that is a quoted identifier refers to a non-file module declaration using the identifier. This form of module reference makes the most sense in a REPL.

What is module path and class path?

A CLASSPATH is a sequence of classes' base paths and JAR files for the Java Compiler or JVM to locate the classes used in the application. Similarly, in JDK 9, a MODULEPATH is a sequence of modules' base paths and Modular JAR files for the Java Compiler or JVM to locate the modules used in the application.

What is module info java?

module-info. java file. It declares the dependencies within the module system and allows the compiler and the runtime to police the boundaries/access violations between the modules in your application.


1 Answers

From Javadoc of System.getProperties:

In addition to the standard system properties,
the system properties may include the following keys:

Key                      Description of Associated Value
jdk.module.path          The application module path
jdk.module.upgrade.path  The upgrade module path
jdk.module.main          The module name of the initial/main module
jdk.module.main.class    The main class name of the initial module

So you should use System.getProperty("jdk.module.path")

like image 140
ZhekaKozlov Avatar answered Oct 09 '22 15:10

ZhekaKozlov