Java                                                          Home : www.sharetechnote.com

 

 

 

 

Java - Hello World

 

As in any programming language course, the first step to write a Java program is to write a program to print out 'Hello World' on command window. Usually the purpose of any HelloWorld example is not only to show the basic syntax and program structure but also to show overall procedure of programming of the specific language. The purpose of this HelloWorld is to show you the three steps listed below.

 

 

Step 1 : Write a HelloWorld.java file as shown below. I will not explain anything about the meaning of each line of the code. Just type in the code as shown here or copy & paste the code.

 

 

Just in case you want to copy and paste the code instead of typing in, here goes the text file of the code.

HelloWorld.java

    public class HelloWorld {

     

        public static void main(String[] args) {

            System.out.println("Hello, World");

        }

     

    }

 

 

Step 2 : Compile the code. Once you created a java file, you can compile it using javac.exe (Java compiler) as shown below. Once the compile is done, you can confirm that a binary file(HelloWorld.class file in this case) is created as shown below.

 

 

 

Step 3 : Execute the compiled code using java.exe as shown below. (NOTE : you shouldn't put any file extention to the class file that you want to run. Try 'java HelloWorld.class' and see what kind of problem happens)