• Step 1: Open notepad and write a program. Copy paste the below program in notepad.


  •  
    
    
    class HelloWorldApp {
        public static void main(String[] args) {
            System.out.println("Hello World!"); // Display the string.
        }
    }
    
    
    
  • Step 2: Save program as HelloWorldApp.java. Check the screenshot for the example. Remember to keep name as file same as name of class containing main function. Also change "Save As type" to All files. Save at Desktop.


  • Executing your first Java program
  • Step 3: Open command prompt and navigate to the location where file is saved. To navigate use cd command as shown below. Press enter.


  • Executing your first Java program
  • Step 4: provide path of the java compiler. Java compiler is usually present in the jdk folder of java. See below screen.


  • Executing your first Java program
  • Step 5: Copy the path and paste into command prompt as shown below. Press enter.


  • Executing your first Java program
    Executing your first Java program
  • Step 6: Execute and run the program. As shown below. The command for compilation of java is "javac HelloWorldApp.java". For execution it is "java HelloWorldApp".


  • Executing your first Java program
  • Step 7: Check the output "Hello World!"