JKB001 - Developing in JDK 1.5 Using Eclipse 3.1 Tutorial

Popular Courses

Browse Our Free Resources

  • whitepapers
  • whitepapers
  • webinars
  • blogs

Our Locations

Training Centres

Vancouver, BC
Calgary, AB
Edmonton, AB
Toronto, ON
Ottawa, ON
Montreal, QC
Hunt Valley

locations map


550 6th Av SW
Suite 475
Calgary, AB
T2P 0S2


821A Bloor Street West
Toronto, ON
M6G 1M1


409 Granville St
Suite 902
Vancouver, BC
V6C 1T2

U.S. Office

436 York Road
Suite 1
Jenkintown, PA

Other Locations

Dallas, TX
Miami, FL

Web Age Solutions Inc.


If you find this topic of interest, you may find the following course to be useful:

WA1278 Introduction to Java Using Eclipse

Eclipse 3.1 is the first release with built-in support for JDK 1.5. Previous releases required manual installation a of patch called Cheetah. In Eclipse 3.1, there is no need to install any patches to support JDK 1.5.

There are three areas that are affected by your choice to use JDK 1.5.

  1. The JRE class library JAR files must be used from a JDK 1.5 distribution. If you have JDK 1.4 or older installed in the development machine and you are not careful, the project may be erroneously built using the JRE JAR files from a non JDK 1.5 distribution. This is extremely dangerous since in the production environment there may be only JDK 1.5 installed.
  2. The compiler must support the JDK 1.5 language syntax as well as produce 1.5 compatible byte code.
  3. The Java 1.5 JVM must be used during unit testing.

Install JDK 1.5 and Eclipse 3.1

Eclipse itself can be run using JDK 1.4 or older. It is recommended that you download and install JDK 1.5 (instead of 1.4). This JDK can be used to run Eclipse as well as develop and unit test the projects. Download JDK 1.5 from and install it.

Download Eclipse 3.1 from this link. Simply unzip the downloaded ZIP file to install Eclipse. Run Eclipse by launching eclipse.exe from the installation directory.

Configure Eclipse

Eclipse uses a built-in Java compiler. The compiler supports Java 1.3, 1.4 and 1.5. The level actually followed by the compiler depends on the project settings. You can configure the Java level per project or set it as a default at a global level.

Launch Eclipse. From the menu bar, select Window->Preferences. Select the Java->Compiler preference. Set the Compiler Compliance level to 5.0.

Click on OK to accept the changes. Click on Yes to do a full rebuild.

Create a Java Project

From the menubar, select File->New->Project. Select Java Project and click on Next. Enter Test as the project name.

Note that system using the default compiler compliance level of JDK 1.5 (shown as 5.0). Click on Next. Click on the Libraries tab.

Note that system has selected the JRE available from JDK 1.5. Click on Finish.

Test Configuration

We are now ready to develop code in JDK 1.5. In the new project, create a package called com.webage.jdk5. In that package, create a class called Test.

Add code shown in bold face below.

import java.util.*;
public class Test {

public static void main(String[] args) { ArrayList<String> l = new ArrayList<String>(); l.add("Hello"); l.add("World"); for (Object o : l) { System.out.println(o); } }

Save changes (Control+S). You should not get any compilation errors.

From the menu bar, select Run->Run As->Java Application.

The code should execute fine. System should automatically pick the javaw.exe JVM from the JDK 1.5 installation directory as shown in the top border of the Console.


Email Address: *

Very useful Somewhat useful Not bad Needs many corrections


( * ) = mandatory field


If you find this topic of interest, you may find the following course to be useful:

WA1278 Introduction to Java Using Eclipse