To setup the Java SE development kit (also known as the JDK)
you can follow these steps on Windows:
Sun's install directions for JDK.
After you agree to the lisense agreement you come to the final download page. Download the file for Windows, the link "Windows Offline Installation, Multi-language". This file is approximately 50 MB. (If a newer edition becomes available, the name and size may be different.)
After downloading, execute this setup program to install the JDK.
This will create a
C:\Program Files\Java\JDKversion
directory by default.
If you rename this directory from this default,
you will have extra work to install the documentation!
Nonetheless, it will simplify advanced Java setups later if you
install to a directory with a short, simple name.
Personally I use C:\Java
as the install directory.
Running the installer is fairly easy.
Accept the license terms.
Next select what to install.
I suggest installing everything except the source code.
(This takes over 300 MB of disk space once installed.)
For each item, select where to install it; I suggest
putting the JDK in C:\Java
.
Note that as part of the JDK, a version of the JRE is installed.
This JRE is used only when compiling code with the JDK tools, such
as javac
.
Next the JRE (used to run programs and applets)
installer will run.
I suggest installing everything, and letting it control all
browsers for applets.
The default location for to install the JRE is
C:\Program Files\Java\jdkversion\
, and
that is fine.
However you will need to note this location down for later.
Onces installed the JRE takes about 110 MB of space.
So make sure you have about 370 MB disk space free before installing.
After the install you can delete the 53 MB installer program.
Note: The JRE is controled by the Java control panel. After the install is completed, you might want to run this control panel and change some of the default settings.
.zip
file.
You need to use Winzip
(or the Window built-in version) to extract the documentation.
You can install the documentation by
extracting all files at C:\Java
(or where ever
you installed the JDK at).
This should create a new directory named C:\Java\docs
.
When you are done, you should set a bookmark (or favorite)
to point to the documentation (the file C:\Java\docs\index.html
)
from your browser of choice.
I would also create a second bookmark to jump right to the API.
javawork
" or some such name.
Also, to run the JDK programs requires typing in long names for
the executables, such as
"C:\Java\bin\javac SomeProgram.java
".
To be able to use short command names
("javac SomeProgram.java
")
you must update the system setting known as the
PATH
environment variable.
Exactly how this is done depends on your version of Windows.
If you wish you can follow the
Sun's install directions for the JDK
to set the PATH
environment variable (step 4) so you can use
short command names.
For the recommended setup, for the current version at the time of this
writting, you should add the following to the front
of the PATH
variable:
C:\Program Files\Java\jre1.6.0\bin;C:\Java\bin;
C:\JavaWork
")
would be most convienent.
For older Windows systems the shourt-cut can also set
PATH
(and possibly CLASSPATH
,
which non-Sun java tools may use in an incompatible way).
The directions below explain how to do this for Windows95/98/ME, and
can be adapted to modern Windows.PATH
(and optionally JAVA_HOME
, which may
be used in more advanded setups), as well as setting
a default working directory and setting (or unsetting)
CLASSPATH
if necessary.
Figuring out how to do this normally requires some understanding of
Windows and DOS, but here are some instructions you can follow
for Windows 98/ME:
CLASSPATH
in AUTOEXEC.BAT
is a bad idea,
as it may mess up Netscape,
JBuilder, and possibly other Java related programs.
(The JDK installation instructions say you don't need to set
CLASSPATH
at all, but this is only
partially true.
If you develop you own packages, or install extra packages of
Java classes, you may need to set CLASSPATH
.)
.BAT
file to setup the
environment for you.
(Not needed for Windows 2000 or newer!)
The .BAT
file should also install
DOSKEY
,
which allows you to repeat previous commands by use of
the up-arrow key.
(On some computers DOSKEY
is already installed
in the AUTOEXEC.BAT
file, which is a good
idea.
If so, don't try to also install it in this .BAT
file.)
The file I created here for HCC is called
SetUpJav.bat
.
The contents of the file should be:
@ECHO OFF SET JAVA_HOME=C:\Java SET CLASSPATH=. SET PATH=%JAVA_HOME%\BIN;%PATH% DOSKEY
(This is a little different than the version at HCC. )
To create this file, copy the above lines to Notepad and then save
the file with the correct name.
(Make sure Notepad doesn't add a ".txt
"
extension to your file.
If so you will need to rename the file by right-clicking on it
and choosing rename.)
This SetupJav.bat
file can be put anywhere
at all.
I recommend putting it in C:\Java\SetUpJav.bat
.
(You should use the actual install directory if different from
C:\JDK
.)
.BAT
file to run and what
the current working directory should be.
The .BAT
file should be the full pathname of the
SetUpJav.bat
file created in the previous step.
(If you followed my recommendation, that pathname is
C:\Java\SetUpJav.bat
.)
At HCC, the shortcut is called Java
.
The Working directory should be set to the place where you
keep your .java
and
.class
files.
At HCC, I have set this directory to C:\temp
,
but at home you may wish to use a different directory.
I personally use the directory C:\JavaPgms
at home.
(Note the directory you name must be created first if it doesn't already exist!)
The easist way to create the shortcut is to copy the shortcut
for MS-DOS Prompt
(or "cmd
"
on more modern versions of Windows) and rename the copy.
To locate this shortcut, right-click on the Start button and choose
"Open".
Now double-click on "Programs" and you should see the shortcut.
Click on it once to highlight it, then choose "Copy" from the "Edit"
menu, then choose "Paste".
Now rename the copy to something like "Java".
When you have finished creating the shortcut, you need to set its properties. Right-click on the new shortcut and choose "Properties" from the menu that appears. Click on the "Program" tab to set the properties:
C:\Temp
or some other directory
created for this purpose.
.BAT
file created earlier, under the heading "Batch file:".
Edit
editor.
Just click the "Screen" tab, then select "50" from the drop-down list.
The shortcut created in the previous step can be copied and placed onto the desktop if you prefer not to use the Start menu.
javac
or java
commands,
it means the PATH
variable isn't set correctly.
You can still run JDK commands by typing in a full pathname, such as
"C:\Java\bin\java
"
if you installed in the recommended location.
If this works, your PATH
is definitely
the problem.
To find out what is wrong with your PATH
:
SET
This should show you the current value of PATH
and other environment variables.
Look at the entry for PATH
.
Are any JDK directories showing?
If so, you probably have a typo so check it carefully.
If not, you probably don't have the .BAT
file listed correctly in the shortcut, or you made a typo in the
SET PATH
statement.
To find out which, close your Java window.
Then add the following line to your
SetUpJava.BAT
file:
echo testing one two three
Save your changes and run your short-cut again.
If the window doesn't show "testing one two three" then your
.BAT
file isn't being run at all.
If you do see the "testing one two three" message the problem must be with the
SET PATH
statement.
.BAT
file isn't
being run, make sure you have the complete pathname listed
in the short-cut property "Batch File:" (and not the
"Cmd Line:" property) as shown above.
SET PATH
command, make sure it looks like this
(it is not case-sensitive, but note there are no spaces around the
equals sign):
SET PATH=%JAVA_HOME%\BIN;%PATH%
Also check JAVA_HOME
for typos.
AUTOEXEC.BAT
.
If so you can either remove the DOSKEY command from your .BAT
file,
or remove it from AUTOEXEC.BAT
, or just ignore the message.
I recommend you remove it from your SetUpJav.BAT
file.
You need to change a property of the short-cut. If the short-cut is on the desktop, you just right click it then choose properties. If the short-cut is under the Start menu, you need to right click on the Start button, then choose open, then double click on Programs. Now right click on the Java short-cut.
Next, click on the "Memory" tab.
Finally, change the value for "Initial Environment" from "Auto" to "512". (If this is too small also, you can try a larger value later. I had to use "2816" on my home computer.)
Now click on OK, and that's it!