HOW To Compile Java Program
There are multiple ways to compile a java program, eventually all other ways of java program compilations at end must 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 Java Installation on windows and install the Java.
Program compilation steps on Linux or on Windows
- Open the DOS Command Prompt in windows or open the ssh 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
Compilation Step 1:
- Open cmd prompt in the windows machine, in case Linux open the SSH terminal
- Check the JDK is installed in the machine, by executing javac command. If you get the result as not found it means JDK is not installed please install it before compiling
Compilation Step 2:
Navigate the program where java program is present or copy the full path including file name
If the java file name is HelloWorld.java then command will be javac HelloWorld.java
In case full path is present then please give the complete path including file name as shown below.