Java Program Compile

There are multiple ways to compile a java program, eventually all other ways of java program compilations at end have to use the javac executable.

Compilation of java program can be done with a single java file or even more, the following are the basic steps for the compilation of any java program.

Java must be installed in the machine, where compilation takes place. If the Java is not installed, please check this post Install Java in Windows and install the Java.

  • Open the DOS Command Prompt in windows or Open the terminal in Unix Shell
  • Navigate to the path where the java file is present by using command cd
  • After navigation, execute the command javac filename.java
  • If the java file name is HelloWorld.java then command will be javac HelloWorld.java
 copy
javac HelloWorld.java

Executable javac will generate one class file with the name of HelloWorld.class with in the same folder, it means compilation is successful.