


This time the extension of the file is excluded. To execute a Java program, the java command is used along with the file name. The compilation error must be resolved to proceed further.Īfter the compilation step comes the execution step. Otherwise, a compilation error is shown by the compiler, and. Now, to compile the file, use the javac command along with the filename and its extension, and press enter.

Type cd Java and press enter.Įventually, we have reached our destination folder. Now, we have to select the Java folder where we saved our file. Type D: and press enter to change the drive from C to D. Therefore, first, we have to change our drive from C to D. Now move to the folder where we save our file. We have saved it to the Java folder of the D drive. The name of the file should match with the class name. Save the file and provide the name of the file. Let’s write a simple Hello-World Java program. Now, write any Java program on one’s choice. Or press Windows + R, then type notepad++ and press the OK button.Īfter pressing enter key or OK button, it opens the notepad++. In the search area of the taskbar enter notepad++ and press enter. However, in this section, we will stick with notepad++. To write a Java program, a text editor is required. It denotes that Java is installed in the system. Observe that after the command java, some information is shown. If the PATH variable is set properly, the information mentioned in the above snapshot is shown otherwise, the command not found! message is shown.Īfter checking for the javaccommand, enter the command java and press enter. In the command prompt, type the command javac and press enter. The other approach to open the command prompt is to press Windows + R, then type cmd and press the OK button. To check whether the PATH variable is set or not, open the command prompt by writing cmd in the search area of the taskbar and press enter. Note: One must ensure that Java is installed in one’s system and PATH variable is set properly. In this section, we will learn how to write, save, compile, and execute or run a Java program in the Command Prompt. How to run Java Program in Command Prompt
