2010. február 16., kedd

Installing JDK on Windows XP

To be able to compile and run Java programs on your computer, you will need to have a Java compiler and a Java Virtual Machine installed.

The Java compiler comes with the JDK (Java Development Kit). The Java Virtual Machine (JVM or Java Run-time) can come with a package called JRE (Java Runtime Engine) or it is also part of the JDK.

As the first screenshot shows, my system didn't have javac installed (or at least coudn't find it in the Path).

It does have Java installed:


Running java without arguments gives the help output. So far, so good.

Now we go to http://java.sun.com






Click on download, choose Java SE, and download the JDK.


Choose your platform, Windows and download the file (76MB).



Get around the safety warnings if you are using IE, and download the file (Save it).

Double click it to run the installer.

After installation, you are still not able to run javac from the command line!

If you left everything on default, the JDK gets installed in:

C:\Program Files\Java\jdk1.6.0_18

Executable programs in:

C:\Program Files\Java\jdk1.6.0_18\bin

So let's try adding this folder to the path.

Right click the My Computer icon on the Desktop, choose properties from the menu.



Choose the Advanced tab, choose the Environment Variables button.



On the second pane (System Variables), select the variable named Path, click the Edit button.


Do not remove the value of the variable! Append a semi-column (;) to the stuff that is already in there, and append the name of the folder that contains javac.exe (C:\Program Files\Java\jdk1.6.0_18\bin).



Hit OK a couple of times until all the dialogues are gone.

Close the cmd window if you had it open (the Path variable will not have changed in there).

Open a new Cmd window (Windows Start menu, Run... enter cmd).

Type javac

It should output a help message with possible options.

Save your java file, here in the example Mississipi.java, for example to the Desktop

Change your directory to the Desktop:

cd Desktop

Compile it using:

javac Mississipi.java

Run it using:

java Mississipi



Have fun!