Java Magazine, Sept/Oct 2017
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2017 30 java 9 Packaging a module into a modular JAR file You can use the jar command to package an exploded module folder as a modular JAR file that contains all of the modules files including its module info class file which is placed in the JARs root folder When running the app you specify the JAR file on the module path The folder in which you wish to output the JAR file must exist before running the jar command If a module contains an apps entry point you can specify that class with the jar commands main class option as in jar create f jars com deitel welcome jar main class com deitel welcome Welcome C mods com deitel welcome The options are as follows create specifies that the command should create a new JAR file f specifies the name of the JAR file and is followed by the name in this case the file com deitel welcome jar will be created in the folder named jars main class specifies the fully qualified name of the apps entry point a class that contains a main method C specifies which folder contains the files that should be included in the JAR file and is followed by the files to include the dot indicates that all files in the folder should be included Running the Welcome app from a modular JAR file Once you place an app in a modular JAR file for which youve specified the entry point you can execute the app as follows java module path jars com deitel welcome or using the abbreviated form java p jars m com deitel welcome
You must have JavaScript enabled to view digital editions.