
Use the following command to run the Hello World program in command prompt window: java HelloWorldĪ message - Hello World! will be displayed on command prompt window. This compiled file will used by JVM to run the Hello World program. Tip: javac is Java compiler to transform the Java source code to bytecode.Īfter compilation complete, a HelloWorld.class file will be generated under same directory. Open command prompt window, go to the directory where the HelloWorld.java you saved in Step 3.Ĭompile the HelloWorld.java with the following command: javac HelloWorld.java Note: Java file name must same with Java class name. Tip: The main method is the starting point of Java application when we run the Java program. In this tutorial, I will save the file to C:\ directory.Ĭ:\HelloWorld.java // Java Hello World Program Open Notepad text editor, write the Hello World program and save the file at any location you want with file name HelloWorld.java.


Note: This set up is required for you to compile and run Java program using command line.

Set Up JAVA_HOME and PATHĪfter JDK installed, set up JAVA_HOME environment variable and add the JDK bin directory to the system’s PATH. What We Usedĭownload Oracle JDK 1.7 installer from Oracle JDK download page and install it on your Windows operating system. In this tutorial, we’ll walk you through how to write a simple Hello World Java program using Notepad, compile and run the Java program using command line. This tutorial is targeted for Java beginner.
