Beginning Programming with Java: Installing JDK (for Windows)

This item was filled under [ Jazzed Up! ]

This was first posted in my old, dead blog “Jazzed Up!” on Jan 28, 2008 11:17 AM

Wanted to learn java but never knew where to start? Well, if you have ever tried downloading the Java SE Development Kit (JDK), you might have found out that just installing it does not let you start programming right away! There are a few things to be taken care of. For people who came here looking for instructions after downloading the JDK, skip to the installation part.

Step 1: Downloading the Java Development Kit

For any programming language, you need to get some necessities in order to begin. For beginning programming in java, you’ll need the Java Development Kit. When I’m writing this, the latest version seems to be JDK 6 Update 4. So download it. If you are having problems downloading, I’ll outline the steps quickly.

Select platform: Windows, check I agree to the Java SE Development Kit 6 License Agreement (I doubt if anyone’s going to read this!?) and click Continue. Check the Windows Offline Installation and press Download Selected with Sun Download Manager. You’ll get a downlaod prompt for a .jnlp file. Either open it on the fly or download it and open it. Now the Sun Download Manager will open. Cool, isn’t it? Enter your download destination and then finish off with the settings. Your download of the JDK will now start. In case it doesn’t start, press the Start button.

Step 2: Installing the Java Development Kit

To install the JDK, browse to the location where you had downloaded the JDK(most probably a file called jdk-6u4-windows-i586-p.exe) and double click on the it. Go through the normal installation process and then reboot(only if the installer asks you to).

You have installed all the files necessary for compiling and running your first java program, but it will be a bit tedious now. You will have to provide the full path to the java compiler (C:\Program Files\Java\jdk1.6.0_04\Bin) each time you compile a program. Do you want to do that? I don’t think so. So now, lets make the process easier by setting the PATH and the CLASSPATH. Don’t worry about what they are right now.

Step 3: Setting the PATH and CLASSPATH

1. Right click on the My Computer icon and click on Properties.

2. Open the Advanced tab and click on Environment Variables(wow! this is something new isn’t it?)

3. Click the New button for System Variables. Type the Variable name as

JAVA_HOME

and the Variable value as

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

Please note that you need to type the location of your installation directory. It may vary on where you installed the JDK. So make sure you are typing the correct path.

Click OK to finish the process.

4. Now scroll down in System Variables itself to find PATH. Select it and click the edit button. Warning! Do not delete the existing value

Add this to the beginning of Variable value

.;%JAVA_HOME%\bin;

5. Click the New button again

Enter the Variable name as
CLASSPATH

And the Variable value
.;%JAVA_HOME%\lib\tools.jar

and finally click the OK button.

6. Apply the effect (Press OK for the Environment Variables windows, APPLY and the OK for the Advanced tab)

Finally, exit all windows (close all command prompt windows, if any) for the change to take place.

I just found a much better way to set the path. Here is what you have to do:

1. Open the Run dialog box by pressing Win + R or by clicking on Run from the start menu.

2. Type notepad C:\autoexec.bat and press enter.

3. Most probably, a blank notepad file would open. Type the following

set path = C:\Program Files\Java\jdk1.6.0_04\bin

and then save it.

4. Reboot your computer to start off writing your first program ;-)

Step 4: Testing a Program

If you are new to java, you can test the your first java program by following the instructions given here

In any case, here is a sample program if you’re to lazy to click on the link above

1
2
3
4
5
class HelloApp {
public static void main(String Args[]) {
System.out.println(”Hello World!);
}
}

I hope this tutorial could help you. If you like this, then be sure to Stumble it.

Cheers

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment