Tuesday, October 7, 2014

My First Java Program

My First Java Program.... 

NOTE : The example explained based on the windows environment.

Requirements :

Download JDK from here.

1. Set up the JAVA_HOME.
  • Right click My Computer and select Properties.
  • On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, 
                  C:\Program Files\Java\jdk1.6.0_35

2. Copy the following content to Nodepad and save as "HelloWorld" java file.

1
2
3
4
5
6
class HelloWorld{
  public static void main(String args[]){
      System.out.println("Hello");

  }
}


3. Open the command prompt and type the below commands.

For compile the java file, 
javac HelloWorld.java

For execute the complied java class
java HelloWorld




No comments:

Post a Comment