Executable | Java options | Example(s) | Explanation |
---|---|---|---|
java | --list-modules |
java --list-modules java -p MyFirstModule.jar --list-modules |
List visible modules. If you do not specify a module path, you'll get a listing of the modular Java Development Kit. If you specify directories in the module path, you'll include visible modules in those directories (either exploded directories or jar files). |
java | -p --module-path |
java --module-path . -m MyFirstModule java -p . -m MyFirstModule |
You need to specify the module path when executing a module jar. |
java | -m --module |
java -p . -m MyFirstModule java -p . --module MyFirstModule |
You need to specify the module name when executing a module jar. |
-p and --module path
-m or --module
Executable | Java options | Example(s) | Explanation |
---|---|---|---|
java | --dry-run | java --dry-run -p . --module MyFirstModule | The --dry-run option loads the main class but does not run it, used for testing module dependencies are satisfied. A successful result is no output. |
java | -d --describe-module |
java --module-path . --describe-module MyFirstModule java -p . -d MyFirstModule |
The --describe-module option gives you summary information about a module including its path, its dependencies, and its packages and resources. |
--describe-moduleThe describe module option gives you summary information about a module including its path, its dependencies, and its packages and resources.
Executable | Java options | Example(s) | Explanation |
---|---|---|---|
javac |
--module -m |
javac -d out\production --module-source-path . --module MyFirstModule javac -d out\production --module-source-path . -m MyFirstModule |
When you compile using --module, you must also specify --module-source-path. |
javac |
-p --module-path |
javac -d out\production -p . --module-source-path . -m MySecondModule | You use --module-path with javac when your code has a dependency on existing modules. |
jar |
-d --describe-module |
jar --file MyFirstModule.jar --describe-module jar -f MyFirstModule.jar -d |
The --describe-module option for the jar command is similar to the java one, but includes the main-class as well. |