Monday, September 10, 2007

How to configure java in windows environment

To use java tools (javac, java, applet viewer etc.) from anywhere in the dos prompt java should be configured. Suppose that you have already installed java and the installed path is "c:\j2sdk1.4.0" and you have installed windows to "c:\".

Java can be configured both temporary and permanently. Note that the temporary configuration will only limit to the dos windows we used to configure.

So first of all let's see how to configure temporary.

STEP 1: Open dos prompt (Click on Start then Run, type "cmd" and press Enter).

STEP 2: Issue the following command and press Enter.
set path=c:\j2sdk1.4.0\bin;

That's all you have to do and now you can use any java tool from anywhere in the dos prompt.

Next we'll see how to configure java permanently.

STEP 1: Select AUTOEXEC.bat file, right click the mouse button and click on edit.
(AUTOEXEC.bat file is in "C:\" and it's hidden by default. So to see it you have to select "Show hidden files and folders" and disable "Hide protected operating system files (Recommended)". Click on OK. This will ask for confimation and click on Yes.

STEP 2: Enter the following two lines and save the file
set path=c:\j2sdk1.4.0\bin;
set classpath=c:\j2sdk1.4.0\lib\classes.zip;

STEP 3: Select My Computer, right click the mouse button and click on properties. Click on the Advanced tab. Click on "Environment Variables".

STEP 4: Click on "New" in the "System variables" section on "Environment Variables" dialog box.

STEP 5: Enter Variable name and variable value as follows on the "New System Variable" dialog box.

Variable name: set path
Variable value: c:\j2sdk1.4.0\bin;

Click on OK.

STEP 6: Repeat STEP 4 and enter varible name and variable value as follows on the "New System Variable" dialog box.

Variable name: set classpath
Variable value: c:\j2sdk1.4.0\lib\classes.zip;

Click on OK.

STEP 7: Click on OK and again on OK.

STEP 8: Restart the computer.

Now you have configured java permanantly.

Special thanks to Mr.Kooragoda @ IDM Galle branch