Thursday, 26 July 2012

Java Hello World (First java program)

[KEY : HELLO WORLD, JAVA FIRST PROGRAM, RUN JAVA PROGRAM] Java Hello World program(first java program)
  1. Make sure class path has been set.(To set class path: Copy your bin folder location-> Right click on "My Computer" icon -> Select Advanced tab -> Click on Environment Variable button -> From System variable pane(lower pane) select path click on Edit button -> At variable value field put semicolon (;) and paste bin folder location and save )
  2. start notepad and copy the following code

    class Helloworld
    {
      public static void main(String str[])
      { 
        system.out.println("Hello World");
      }
    }
    

  3. Save file as Helloworld.java(same as your class name).
  4. Open CMD goto your folder where program is saved.
  5. Type javac Helloworld.java(it will compile you program).
  6. Now run with java Helloworld