How To Compile A Java File(s)
Compiling a Java file requires the use of Windows Command Prompt (Windows), Terminal/Shell (Mac & Linux), or an IDE.
The screenshots below are from Windows Command Prompt, but the java commands will look the same whether using Windows, Mac, Linux, or remote terminals such as PuTTY.
Change the working directory to the location in which the .java file you wish to compile is contained. For the screenshot below, for example, the working directy was e:\csci wiki\java
Type javac filenameX
, where filenameX
is the name of the file to be compiled, and press the Enter
For compiling multiple files, put a space between the filenameX
To compile all
.java files in the directory use *.java
There should now be a .class
file with the same name as the .java file.