| Date tip published: | 10/25/2004 |
| Description: | WebSphere Studio 5 can support multiple versions of the Java compiler (SDK). WebSphere Studio ships with 1.3.1 of Java J2SE SDK. There will be occasions when a programmer will need to install a newer version of the Java SDK to support a new feature. This tip will show you how to install additional Java SDKs into WebSphere Studio and how to use those SDKs in your project. |
To learn more about Java and WebSphere Studio use the following links:
Introduction to WebSphere Studio 5
Servlet and JSP Programming using WebSphere Studio 5
Introduction to WebSphere 5 for Domino Developers
Servlet and JSP Programming using WebSphere 5 for Domino Developers
Adding an Additional Java SDK to WebSphere Studio
WebSphere Studio 5 ships with version 1.3.1 of the Java SDK. For some of your Java projects you may need to use a different SDK. For example, there were quite a few enhancements added to version 1.4 of the Java Sun SDK including XML parsing and regular expressions for string matching. Another reason to use a different SDK is when preparing for the Sun certification exams. The Sun Certified Programmer certification test is based on 1.4 (an older exam for version 1.2 is still available.) If you are preparing for this exam you should install the Java Sun 1.4 SDK. Sun recently announced version 5 of the Java Sun SDK. Programmers may want to start learning and using this new version of Sun Java. All of these versions can be installed into WebSphere Studio as alternative compilers.
It is important to consider the target platform of your application when choosing an Java Sun SDK version. For example, if the code you are developing in WSAD will be used in Domino 6 than version 1.3 of the Sun SDK should be used. Domino R5 servers (5.0.13) used version 1.1.8 of the Sun JVM.
The key point is to match your development environment's (WebSphere Studio) compiler with the intended deployment platform. If your code is developed with a later version of the Sun SDK using classes which do not exist in the target platform's SDK than your code will not run.
There are three steps to use an alternative Java compiler in WebSphere Studio:
- Install and download the Java SDK to your system from the Sun website
- Add the additional JRE (Java Runtime Environment) to WebSphere Studio
- Specify the desired Java SDK in your WebSphere Studio Java project
This tip will cover all three steps. This tip will illustrate installing and setting up the J2SE 1.4 Java SDK with WebSphere Studio.
Procedure: Download the Java SDK from Sun
The first step is to download the desired Java SDK.
- Go to the Sun Java website.
Click here to go to the Sun Java site.
- Choose which Sun Java environment you want. In this case, version 1.4.2. Click on the version number to go to that version's home page:

- Click on "Downloads" in the top left corner.

- Make certain to download the SDK (Software Development Kit) not the JRE (Java Runtime Environment) for 1.4.2. The link is highlighted below:

- Follow the instructions to complete the download process. There are two options to install. You can download the complete installation kit (about 55MB) or download a small installation program which will then download only the necessary components as you go through the installation procedure.

- Follow the Install prompts to complete the installation.
Procedure: Add the new Java SDK to WebSphere Studio
The next step is to add the Java Runtime Environment to WebSphere Studio.
- Start WebSphere Studio.
- Select Window | Preferences from the menu.

- On the left side expand "Java" and then click on "Installed JREs". Click the [Add...] button.

- Enter the following:
JRE Name - Any descriptive name.
JRE home directory - The root directory where the Java SDK was installed.
Javadoc URL - The location of the Javadoc documentation for this SDK. Unless you downloaded and installed the documentation you can use the URL to the Sun website (for the J2SE 1.4 SDK use http://java.sun.com/j2se/1.4/docs/api.)
Click OK when done.

- The new Java SDK will be saved and listed in the list of Installed Runtime Environments. Click [OK] to save the Studio preferences.

Procedure: Use the alternative Java SDK in your WebSphere Studio Java Project
The next step is to use the new Java SDK in a Java project.
- Right click on the Project name and choose Properties from the context menu.
- On the left side choose "Java Build Path". Click the "Libraries" tab.

- Click the [Add Library...] button

- Choose JRE System Library and click Next.

- Choose the JRE you added in the previous procedure and click [Finish].

- You will see the new JRE in the list. You may want to remove the existing standard Eclipse JRE. This helps to avoid where your code could find a class with the same name, but from the standard Java compiler that comes with WebSphere Studio. You can also use the "Order and Export" tab to reorder the libraries.

- Click [OK] when done. Your code will now use the new Java SDK when compiling this project.
|