Don't worry if you don't understand the code above - we will discuss it in detail in later chapters. For now, focus on how to run the code above.

Save the code in Notepad as "MyClass.java". Open Command Prompt (cmd.exe), navigate to the directory where you saved your file, and type "javac MyClass.java":


C:\Users\Your Name>javac MyClass.java

This will compile your code. If there are no errors in the code, the command prompt will take you to the next line. Now, type "java MyClass" to run the file:


C:\Users\Your Name>java MyClass

The output should read:


Hello World


public class MyClass {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}


Output.


C:\Users\Name\java MyClass

Hello World


Jay Kakadiya

Jay Kakadiya Creator

I am a computer field, & i am Web developer.

Suggested Creators

Jay Kakadiya