Instructions for downloading and installing the Java Development Kit (JDK)
The Java compiler, which is required to compile Java programs, is included in a software package named Java Development Kit (JDK). To compile and execute the programs that are presented in the book, you need JDK version 5.0 or some later version.To install the JDK to your computer, you need first to get an installation file from the pages of Sun Microsystems, the company where Java was invented. You can download the JDK installation file from the address
http://java.sun.com/j2se/1.5.0/download.jspBefore you click the above address and go to the pages of Sun Microsystems, you should have a folder (directory) on your computer into which you download the installation file. I'm supposing here that D:\setupfiles is the folder into which the downloaded files are put.The above address provides several Java-related software packages. What you should download from the above address is JDK 5.0 Update 6. (JDKs with larger version numbers and update numbers are also acceptable as they become available in the future. Here, I suppose that the JDK version number is 5.0 and update number is 6.) After you have clicked the link to download JDK 5.0 Update 6, you'll see a new page which provides JDK versions for different computers or platforms. As I'm supposing here that you are using a Windows computer, you should select the JDK for the Windows platform. Before you can select the platform, you should accept a License Agreement by making an appropriate selection on the page. If you accept the License Agreement, you can click on "Windows Offline Installation, Multi Language".
When you are shown a File Download dialog box, you should press the Save button, and select the folder D:\setupfiles as the folder where the installation file will be saved. After you have selected the folder, the downloading process begins, and a file named jdk-1_5_0_06-windows-i586-p.exe will be transfered to your computer. Downloading time depends on the speed of your Internet connection. As the size of the installation file exceeds 50 megabytes, it may be better not to download it with a modem-based connection. After the download is complete, you can close the possibly open status window. When the installation file in a local folder in your computer, you can start the actual installation.
THE ACTUAL JDK INSTALLATION
After you have downloaded the file jdk-1_5_0_06-windows-i586-p.exe, you can start the installation. The installation is described below.Select My Computer > Local Disk D: > setupfiles > jdk-1_5_0_06-windows-i586-p.exe
By double-cliking the file name jdk-1_5_0_06-windows-i586-p.exe you can execute the file, and thus activate the installation process.
After some preparations the installation program displays a License Agreement . If you accept the License Agreement, select "I accept the terms in the license agreement", and click Next.
After this you'll see a Custom Setup window where you can select the program features to be installed. I suggest that you install what are proposed. However, here it may be better to change the folder where the JDK will be installed. If you have both C: and D: hard disk drives in your computer, and there is plenty of disk space on disk D:, it is better to select a folder on disk D: Thus you can click the Change... button and write D:\jdk1.5.0_06\ to the Folder Name field. This way the files will be installed in a folder named jdk1.5.0_06 on Local Disk D: (Drive D:).
After you click OK, you will go back to the Custom Setup window. When D:\jdk1.5.0_06\ is mentioned as the installation folder, click Next.
(It is possible to install the JDK into the folder which is proposed by the installation program, but I have found that in my computer it is best to not to put too much stuff on Local Disk C:)After you have clicked Next, the installation of the Java Development Kit begins and you'll be displayed the Installing window. That window tells the status of the installation. The installation took something like 5 minutes on my computer. It can be slower or faster on your computer.
After the installation of the actual JDK is complete, the installation program starts installing the Java Runtime Environment (JRE). You'll again see a License Agreement where you need to select "I accept the terms in the license agreement" and click Next if you accept the agreement.
Then you'll see a Custom Setup window where you can select the JRE components to be installed. I suggest that you install the proposed components and install to the proposed folder. After you click the Next button, you'll be shown a Browser Registration window in which you can select the browsers that should use the Java Runtime Environment (JRE). You can let the browsers use the JRE, and click Next.
After you have clicked Next, the installation of the Java Runtime Environment begins, and it takes a few minutes.
After the installation is complete, you'll be shown a window which informs that the installation was successful. You can click a button to finish the installation.
MAKING THE JAVA COMPILER OPERATIONAL
The free Java compiler that comes with the JDK is a compiler that can be used from the command line. This means that you must invoke the compiler by giving a command in a commmand prompt window. (Read the book to find more information about the command prompt window.) The compiler can be invoked by writing a command likejavac Test.javabut this command does not work unless you have told the Windows operating system where the compiler javac is located. The main program of the Java compiler is located in a file named javac.exe, and you must "explain" to the Windows operating system where this file can be found. One way to tell the Windows opeating system where the javac.exe is located is to give a new value to the PATH environment variable. The PATH variable specifies the search path that is used to seach for programs that are invoked from the command line. The PATH variable can be set as follows. (Note that it is possible to paste text to the Variable value: field with the right mouse button.)First you have to activate the Control Panel through which you can control your computer.
Select Control Panel > System > Advanced
Click the Environment Variables button
In the list "User variables for ..." select PATH and click Edit
If the Variable value: field is empty write there
D:\jdk1.5.0_06\bin
and click OK.
If there already is something in the Variable value: field, write
;D:\jdk1.5.0_06\bin
after the text that already is there, and click OK.
You must click OK in the Environment Variables window.
And also click OK in the System Properties window.With the above operations you tell the Windows operating system that the javac.exe file is in a folder named bin that is in the jdk1.5.0_06 folder in drive D: Before setting the PATH variable, it may be a good idea to explore your computer and check the exact name of the folder that has been created during the installation. You may need to have administrative rights in order to set the PATH variable.
When you have set the PATH variable, you should open a new command prompt window to check whether your Java compiler works. You should see the following output in the command prompt window when you try to compile a non-existent Java program named Test.java
D:\>javac Test.java
error: cannot read: Test.java
1 errorWhen you see the above output, your Java compiler is properly installed.
When there is a Java compiler in your computer, you can compile and execute Java programs as described on page 25 of the book.
If you have successfully installed the electronic material of this book, you can execute the program in file First.java with the following commands
D:The first two of the above commands make D:\javafiles1 the current folder (directory) in the command prompt window. The last line is the actual compilation command. If the compilation is successful, you can execute the compiled program by typing
cd javafiles1
javac First.javajava First
To www.naturalprogramming.com
To personal homepage of Kari Laitinen
![]()
Page created: August 22, 2005
Last modification: March 1, 2006