Pages

Sunday, November 13, 2011

Java Hello World

Basic Java Program
This is the first step to the java world. Here i am going to explain how can a simple string "Hello World" print or display in the command prompt. For this all we need is the JDK(java development kit).
You can download it from the link given below. If you had it, then you are ready now.
  Just install it and find the path where the jdk is located and the find the bin folder (for 64bit os it is "C:\Program Files\Java\jdk1.7.0_01\bin" , for 32 bit os it isC:\Program Files (x86)\Java\jdk1.7.0_01\bin) 
If you have any other version of java then you can replace the version no with yours..



Initialization Steps
Open cmd(smpliply press windows+R then enter cmd and press enter) 
then type set path="C:\Program Files (x86)\Java\jdk1.7.0_01\bin" 
about loaction replaced by yours
the initial steps completed.


Hello World Program

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

simply copy this program and paste it into a text file and save it as "HelloWorld.java"
java is case sensitive. Normally the starting letters of each word in the name of a class will be Upper Case
And the file name should be the name of the class which contains public static void main

Compilation And Running
For compilation we use a command "javac" and for running we use "java" command 
enter The command as shown below . for any other program only thing you have to do is just chang the file name..


  
Output


Download Links

JDK 7.01  

hello_world.rar

No comments:

Post a Comment