The Java 2 SDK (Termed Java 2 by SUN, referring to JDK 1.2.x or JDK 1.5.x or JDK 7) Standard Edition is available freely at http://java.oracle.com. This year, I recommend that you download JDK 7 (currently release 45).
We will cover some of the new features of recent JDKs such as, Metadata, Generics, Enumerated types and Autoboxing of primitive types. However, we will walk before we can run and cover these at the end of the module.
The JDK provides the basic tools of:
javac - The Java programming language compiler.
java - The run-time environment for developed Java applications.
appletviewer - A basic Java enabled browser.
javadoc - Automatic API documentation tool.
jdb - The embedded Java debugging tool.
javah - A native development tool for creating C headers.
javap - A class file disassembler.
It also includes a set of advanced tools for performance analysis, security, Remote Method Invocation (RMI) and internationalisation.
The Java 2 Platform features are illustrated in Figure 5.2, “The Java 2 Platform Overview (Figure from java.sun.com)”  .
Figure 5.2. The Java 2 Platform Overview (Figure from java.sun.com Version 1.4)
Installation of the Java 2 Software Development Kit
Please note that if you have set up Eclipse using my instructions earlier in the year, you should have a working JDK, so you can skip this step. Go straight to "Testing The JDK" below. These instructions are still present in case that something goes wrong.
The latest release of the Java 2 Software Development Kit is Java JDK 7. To install this on your home PC, please take the following steps:
Download the Java Development Kit from: java.oracle.com. Follow the link on the right hand side of the page for "New Downloads" -> "Java SE 7 Update 45" (or the equivalent). Choose the "Java Platform (JDK) 7u45" (or equivalent). Click the radio item to "Accept License Agreement" and then choose the version for your machine. Mine is a Windows 7 64-bit installation, so I chose "jdk-7u45-windows-x64.exe"
Download the J2SE 7.0 Documentation also (http://www.oracle.com/technetwork/java/javase/downloads/index.html) if you do not have a stable internet connection.
Execute the installation (.exe) file and allow it to complete
a full install. Choose the default directory.
Extract the documentation to a suitable directory, for example:
c:\jdk7\docs using a
.zip extractor. If you do not have one installed, use winzip or 7zip etc.
You should not have to do this step - test first! Set your PATH to include the
bin directory of the installed folder (e.g.
c:\jdk7\bin). See Figure 5.3, “Setting the Java Environment Variables.”.
You should not have to do this step - test first! Set a new CLASSPATH environment variable to include the file
c:\jdk7\jre\lib\rt.jar and the current directory - so it should have the form
See Figure 5.3, “Setting the Java Environment Variables.”. This is my setting on Windows XP Professional (very similar for Windows 7/8)
Figure 5.3. Setting the Java Environment Variables.
To test the JDK, we will use the Hello World application. Here is the
public class HelloWorld
public static void main(String args)
To compile and run this application, perform the following steps:
Open Notepad, or any other text editor (not MS Word) and paste the code above into the editor.
Save the as
HelloWorld class must be placed in a file of the same name. Note: if you are using notepad, please place inverted commas around the file name (e.g.
"HelloWorld.java") or it may be saved as
Compile the (
.java) source file, by typing "javac HelloWorld.jav
a". If you receive a "command not found" error then your PATH environment variable may be incorrect. Any other errors could mean that your CLASSPATH is incorrect.
Execute the (
.class) bytecode file, by typing "java HelloWorld". Note that the file-type extension is omitted and the exact case must be supplied (i.e. capital H and W).
See Figure 5.4, “Testing the JDK.” to see this code example working on my PC.
Figure 5.4. Testing the JDK.
If you get the same results - you have installed everything correctly - congratulations!
The Java Runtime Environment (JRE)
The Java JDK 6 release also included the Java Runtime Environment (JRE), that consists of the JVM, the Java platform core classes, and supporting documentation. The JRE is aimed at developers who wish to distribute their applications with a runtime environment. The SDK is large and licensing also prevents the distribution of the JDK.