by @kodeazy

Java How to create Hello World program and execute?

Home » java » Java How to create Hello World program and execute?
  • create a file with name FirstProgram.java and add the below code.

    class FirstProgram {
    public static void main(String[] args) {
        System.out.println("Hello World"); 
    }
    }
  • Now open the command prompt and try executing the below commands.
  • compile the code with below command.

    javac FirstProgram.java
  • run the code with below command.

    java FirstProgram

    Output

    Hello World