How to Compile Multiple Java Files from a Single Command in Java
If you need to compile multiple Java files using a single command, then you can do the following.
First, it’s good to learn how to compile a Java file.
How to Compile a Java File
Let’s take the following Java code:
To compile this, we simply do the following:
|
|
Then when we need to run it, we do:
|
|
We now get the output of Hello World
.
How to Compile All Java Files in the Current Directory
If you have multiple files in your current directory, then you can issue the following command:
|
|
Alternatively, you can specify a directory where your Java files live:
|
|