Java examples for Object Oriented Design:Module
Use the javac utility to compile the module.
Specifying the d flag to list the folder into which the compiled code will be placed.
After the d option, each of the source files to be compiled must be listed, including the module-info.java descriptor.
Separate each of the file paths with a space.
javac d src/mods/org.firstModule src/org.firstModule/module-info.java src/org.firstModule/ org/firstModule/Main.java
To execute the module, use standard java executable with the --module-path option indicating the path of the module sources.
The -m option is used to specify the Main class of the module.
java --module-path mods -m org.firstModule/org.firstModule.Main
The syntax for compiling two modules that contain a dependency is as follows:
javac -d mods --module-source-path src $(find src -name "*.java")
The standard javac utility has been enhanced so that it can accommodate the compilation of modules.
The d option is used to specify the destination for the compiled sources.