If you have , for example, 3 files with the same package declaration of:
package com.modemnoise.code;
To compile this from the command line you would navigate to the directory in your terminal and execute the following line:
javac -d . *.javaYou can then execute your file (yourFile.class) like so:
java com.modemnoise.code.yourFileThe folder structure will be as expected for packaged code i.e. .\com\modemnoise\code\yourFile.class The -d switch tells the compiler the code is to be compiled in an existing directory and the period(.) tells the compiler to start in the current directory. After this the compiler recognises the package declaration and creates the structure for you.
Oracle javac tech note
No comments:
Post a Comment