How to install and use the JDK
The
Java 2 SDK is a software development kit made available for free by Sun Microsystems.
The package gives you all the tools necessary for creating Java applications and
applets
The
current version of the SDK is J2SETM 1.4 (JavaTM 2
Standard Edition v 1.4) and this is the version we use on this course.
The
following steps explain how to install the J2SETM on your PC running
Windows 9x and NT(2000,XP).
Installing
the JDK
Modifying
your Path
Running
your first program
Installing
the JDK
-
Obtain
the
Java 2 SDK from Sun
You
can download the installation file directly from Sun's website at:-
http://java.sun.com/j2se/1.4/download.html
You
should ensure you download the SDK
(Software Development Kit) and not the JRE
(Java Runtime Environment.)
You
should end up with a file called j2sdk-1_4_0_01-windows-i586.exe
-
Uninstall any Prior Version of the Java 2 SDK
If you have previously installed another version of the Java 2 SDK, uninstall it.
Use the Microsoft Windows Add/Remove Programs utility, accessible from the Control Panel (Start --> Settings --> Control Panel).
-
Run the Java 2 SDK installer
Note -- you must have administrative permissions in order to install the Java 2 SDK on Microsoft Windows 2000 and
XP.
The file j2sdk-1_4_0_01-windows-i586.exe
is the Java 2 SDK installer. Double-click on
the file to start the installation.
When
the installation starts, you will be presented with the InstallShield
screen. Click on "Next" and then "Yes" to accept the
license agreement. You will be prompted for the installation
directory. Choose the default directory C:\j2sdk1.4.0_01
and click "Next".
Note
-- you can choose a different installation directory provided there are no
spaces in the path name.
After
clicking on "Next" you will be prompted for the components to
install. All you really need are the
"Program Files", but if you have the space available, you should
install all the components.
On
clicking the "Next" button again you will be asked if you wish to
set the Java Plug-in as default for any browsers you have installed.
Tick all the boxes and click on "Next".
The
installation files will now be copied. When the installation is
complete, a "Setup Complete" window is displayed, and you have the
option to read the README file. Click on the
"Finish" button when you are ready.
-
Delete the downloaded file (Optional)
If you want to recover disk space, delete the file you originally downloaded.
Modifying
your Path
The
PATH variable is used to tell the computer the
location of the java executables (javac.exe, java.exe, javadoc.exe, etc.)
You can run the Java 2 SDK without setting the PATH variable, or you can optionally set it as a convenience.
If you don't set the PATH variable, you need to specify the full path to
an executable every time you run it, such as:
C:> \j2sdk1.4.0_01\bin\javac MyClass.java
If you want to be able to conveniently run the Java 2 SDK executables (javac.exe, java.exe, javadoc.exe, etc.) from any directory without having to type the full path of the
command you should set the PATH variable.
Once the PATH is set, running an executable is
simpler. For example, the command above becomes:
javac MyClass.java
Modifying
your path depends on what version of Windows you are using. Set the
PATH as follows, according to whether you are on Microsoft Windows NT or 95/98/2000/ME.
Setting
the Path - Microsoft Windows 98 and 95
If
you are running Windows 95/98, open the
"C:\autoexec.bat"
file with a text editor like NotePad. All you need to do is add ;C:\j2sdk1.4.0_01\bin;
to the end of the line which contains the
word PATH.
Here
is an example
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\J2SDK1.4.0_01\BIN;
To make the path take effect in the current Command Prompt window, execute the following:
C:> c:\autoexec.bat
To find out the current value of your PATH, to see if it took effect, at the command prompt, type:
C:> path
Your
new path should include the "c:\j2sdk1.4.0_01\bin"
directory. As a final test to make
sure everything has been installed correctly, type "javac"
at the command prompt. If
you get the output:
Bad
command or file name
Then
your path has not been modified correctly. If you get the output:
Usage:
javac <options> <sourcefiles>
followed
by a list of possible options then everything is correctly installed,
and you are ready to start developing Java programs on your PC!
Setting the Path - Microsoft Windows NT, 2000, and XP
Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 2000
and XP select the Advanced tab and then Environment Variables. Look for PATH
in the User Variables and System Variables. Add the j2sdk
PATH to the right end.
Typically you would add:
;C:\j2sdk1.4.0_01\bin;
Click "Set", "OK" or "Apply".
Running
your first program
First
Steps - Using Java
Your computer system should now be ready to use the Java 2 SDK.
To get the feel of some simple java
applets, try running the following applets.
Open
the command prompt and change to the Java C:\j2sdk1.4.0_01\demo\applets
directory by typing
C:>
cd j2sdk1.4.0_01\demo\applets
Now type the following and see what you get.
appletviewer
animator\example1.html
Here
are some more you can try
appletviewer
dithertest\example1.html
appletviewer
clock\example1.html
appletviewer
drawtest\example1.html
Note
-- you can also view any of the applet examples in the demo applet directory
by double-clicking a HTML file. For example, double-clicking the example1.html
file in the animator directory would load the applet into your default browser
Now
try writing your first Java applications and applets >>
|