Sei sulla pagina 1di 2

STEP 1: Install JDK/JRE

Run the downloaded installer, which installs both the JDK (Java Development Kit) and JRE
(Java Runtime). By default, the JDK and JRE will be installed into directories "Program
Files\java\jdk1.6.0_xx" and "Program Files\java\jre1.6.0_xx", respectively, where
"xx" is the update number. For novices, accept all the defaults.

The JDK installed directory is hereafter denoted as $JAVA_HOME (Unix notation) or %JAVA_HOME%
(Windows notation) in this text.

For Advanced Users: The default directories work but I recommend avoiding "Program
Files" because of that blank character in the directory name, which is not Unix-friendly. You
may change the installed directory for JDK and JRE during installation. I personally installed
JDK and other programming tools in "d:\bin" for ease of maintenance.

STEP 2: Include the JDK's "bin" directory in the PATH

Windows Operating System searches the current directory and the directories listed in the PATH
environment variable for executable programs invoked from the CMD shell. JDK's programs (such
as compiler javac.exe and runtime java.exe) reside in directory "$JAVA_HOME\bin" (where
$JAVA_HOME denotes the JDK installed directory you have chosen in the previous step). This
directory needs to be included in the PATH.

To edit the PATH environment variable in Windows XP/Vista:

• Click the "Start" button ⇒ "Control Panel" ⇒ "System" ⇒ (Vista only) "Advanced
system settings".
• Switch to "Advanced" tab ⇒ "Environment Variables..."
• In "System Variables" box, scroll down to select "PATH" ⇒ "Edit..."
• In "Variable value" field, type "c:\Program Files\java\jdk1.6.0_xx\bin" (if this is
your installed directory, change "xx" to the actual update number) in front of all the
existing directories, followed by a semi-colon (;) to separate the JDK's directory from the
rest of the directories. DO NOT delete any existing path entry, otherwise, other
applications may not run. For example,

Variable name : PATH


Variable value : c:\Program
Files\java\jdk1.6.0_xx\bin;c:\windows\system32;c:\windows;...

Refer to "Environment Variable - PATH" for more discussion about PATH environment variables.

For Advanced Users: I suggested that you place the JDK bin directory in front of
"c:\windows\system32" and "c:\windows". This is because some Windows systems may have
an out-dated copy of JDK/JRE in these directories. Do a search for "java.exe", and you will be
amazed of the findings.
STEP 3: Verify the JDK Installation
Launch a CMD shell (click the "Start" button ⇒ run... ⇒ enter "cmd"), and

1. Issue a "PATH" command to list the search paths for executable programs:

> path
PATH=c:\Program
Files\java\jdk1.6.0_xx\bin;c:\windows\system32;c:\windows;...

Check the output and make sure that $JAVA_HOME\bin is listed in the PATH.

2. Issue the following command to check that JDK is properly installed and display its
version:

> java -version


java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

STEP 4: Compile & Run a Java Hello-world Program


Read "Writing your First Java Program with JDK and a Programming Text Editor". Read
"Common JDK Installation Errors", if you encounter problems compiling or running your first
Java program.

STEP 6: Download JDK Documentation

The JDK download does not include the documentation, which needs to be downloaded
separately.

• From http://java.sun.com/javase/downloads, select the item "Java SE 6 Documentation"


(under "Additional Resources") ⇒ "Download". You shall receive a zip-file (e.g., "jdk-
6u18-docs.zip" - about 56MB).
• "Un-zip" into the JDK installed directory (remember to check the "keep folder name"
option). The documentation will be unzipped into "$JAVA_HOME\docs" directory, where
$JAVA_HOME denotes the JDK installed directory. Browse the JDK documentation by
opening "$JAVA_HOME\docs\index.html".

STEP 6: JDK Source Code


Source code for JDK is provided and kept in "$JAVA_HOME\src.zip". Highly recommended to
go through some of the source files such as "String.java", "Math.java", and "Integer.java".

Potrebbero piacerti anche