Hello_World

Code

class Test  
{  
    public static void main(String []args)  
    {  
        System.out.println("My First Java Program.");  
    }  
};

Compile

To compile the program, we must run the Java compiler (javac), with the name of the source file on the “command prompt” like as follows

If everything is OK, the javac compiler creates a file called “Test.class” containing the byte code of the program.

javac HelloWorld.java

Execute

  • Create the program by typing it into a text editor and saving it to a file – HelloWorld.java.
  • Compile it by typing “javac HelloWorld.java” in the terminal window.
  • Execute (or run) it by typing “java HelloWorld” in the terminal window.
java HelloWorld

Resource

GfG | hello world ex