User Tools

Site Tools


how_to_compile_a_java_file_s

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.

  1. 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


  2. Type javac filenameX, where filenameX is the name of the file to be compiled, and press the Enter or Return key.


    • For compiling multiple files, put a space between the filenameX lines.


    • To compile all .java files in the directory use *.java.


  3. There should now be a .class file with the same name as the .java file.


    • If a .class file was not created and there was no error displayed, verify that the .java file begins with a class declaration and try again.

how_to_compile_a_java_file_s.txt · Last modified: 2013/07/25 11:11 by jhuber