If you are a new programmer or already an programmer and want to learn Java, this article is for you to get started in Java by writing “Hello World” program to make sure you compile it on your computer.
The first step is to go to Oracle Site (Since Oracle acquired Sun Microsystems in 2010) and download latest version of JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html
Select the appropriate JDK File. Example, if you are an windows user, select Windows x86 or Windows x64 accordingly.
After downloading, Install Java SE Development Kit
Now add Environment variable at Computer > Properties > Advanced System Settings > Environment Variables > System variables > Path
The path is the bin path of the installed jdk, as in this case is: c:\Program Files\Java\jdk1.7.0_05\bin;
After that go to command prompt to verify the Java is installed and check the verion at command prompt by writing:
You should get the version information accordingly and it should match the version installed otherwise there is something wrong with the environment variable path.
Since JDK is installed, you are ready to write your first Hello World program in Java.
Open notepad and write the following code:
public class HelloWorld
public static void main(String arg)
Save the file at some location (say, C:\test\) with the name “HelloWorld.java”
Open the Command prompt.
Navigate to C:\test
If there are no errors in the program, it will go to command prompt without displaying anything.
The compiler has generated a bytecode file, HelloWorld.class. Check this file at C:\test\HelloWorld.class
Now that you have a .class file, you can run your program.
Now that you have class file generated, run java with name of class, which is
The string “Hello World!” will be displayed in Command Line.