Compile Java files using command line
Author |
Message |
scholarlytutor
![](http://compsci.ca/v3/uploads/user_avatars/1625682006192930720d11.png)
|
Posted: Fri Mar 18, 2022 12:11 am Post subject: Compile Java files using command line |
|
|
Does anyone know how to compile a Java program using command prompt in Windows or terminal for Mac/Linux? I know how to compile simple programs with only a main class, but I am unsure of how to compile several classes together.
I've written all the code on a plain text editor, so are there are any lines of code I need to add to the files before compiling, or do I just need to write a specific command in the terminal? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
scholarlytutor
![](http://compsci.ca/v3/uploads/user_avatars/1625682006192930720d11.png)
|
Posted: Tue Mar 22, 2022 4:12 pm Post subject: RE:Compile Java files using command line |
|
|
For anyone wondering:
I figured out that you just need to write all the names of your classes on the same line. Using the terminal:
javac Main.java OtherClass.java OtherClass2.java
Just make sure they are all in the same folder. |
|
|
|
|
![](images/spacer.gif) |
|
|