I know running javac file1.java
produces file1.class
if file1.java
is the only source file, then I can just say java file1
to run it.
However, if I have 2 source files, file1.java
and file2.java
, then how do I build the program?
Using Argument Files When there are multiple packages to compile, then using the javac command with an argument file comes in handy. An argument file can include both the javac options and source file names.
Description. The javac command reads source files that contain module, package and type declarations written in the Java programming language, and compiles them into class files that run on the Java Virtual Machine. The javac command can also process annotations in Java source files and classes.
Try the following:
javac file1.java file2.java
or you can use the following to compile the all java source files in current directory..
javac *.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With