Thursday 19 September 2013

HOW to Write Compile & Run Java Program on Windows 8 64 bit

How to Write , compile and Run java Program via Commamd Prompt(CMD) in 64 bit Windows

In the previous version of windows writting java programs is done via "edit " command. Bur now in the modern 64bit 
version of windows dont have the classic MS-Editor(edit.exe) thow 32bit versions still have it.. In 64bit Windows the only
option to write any text via CMD is "notepad"........All the procedure is as follows

1. Download latest JDK 64bit  (jdk-7u25-windows-x64) & install it.

2. Richt click on Computer icon(desktop) and click properties
    click Advance System Settings
    click Environment Variables
    In the system variables box click on Path ----Click Edit
    In the variable value just ADD ";C:\Program Files\Java  
    \jdk1.7.0_25\bin" without quotes at last. i.e. Don't delete   
    a single letter of the previous value, only add the above
    text after it
    save every thing you've done by clicking OK.
  Here is the screenshot of the step 2


3. Now open cmd(windows key +R and type cmd & Enter)

4. Type "notepad" without quotes

5. Write your java program and save it in your Home Directory 
   i.e. C:/Users/usrername(currently you have logged in) or You cam Create A folder(suppose named JAVA) to Store all
   your java programs and class files.

6. To set CMD to start in your JAVA folder(the folder you recently created) type CMD in run and Enter,
     Right ckick on CMD icon of tast bar --->Right click on Command Prompt ----> click properties ---->In the starts in box write \JAVA after the %HOMEDRIVE%%HOMEPATH% string. And save
    Now every time you open CMD it will starts in your JAVA folder that u have created in step 6.

7. Save your java program as class name.java( if the class name is Hello then program name should be Hello.java)

8. Compile with javac<space><program name.java> (like    javac Hello.java  )

9. If compilation shows no error tye java<soace><program name>  (like   java Hello ) to run the program.

10. If compilation showa any error type notepad<space><program name.java> ( as notepad Hello.java ) to edit the progrm.