TechTip: Selecting a JDK

Java
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

OS/400 V4R5 already ships with five different,

optionally installable versions of the AS/400 Java Development Kit: JDK 1.1.6, JDK 1.1.7, JDK 1.1.8, JDK 1.2., and JDK 1.3. With all of those installed, how do you determine which to use?

I had to tackle that problem myself because I use several open source Java products that require either JDK 1.2 or JDK 1.3. The easiest solution is to qualify the JDK in the Java command with the java.version option:

java -Djava.version=1.2 TheJavaClassName

However, as with IBM's SQLj utilities, you sometimes don't have access to the Java command. Moreover, adding that option can become tiresome if you want a specific JDK as your default. You can avoid having to manually specify which JDK to use each time by adding java.version=1.2 to a text file called SystemDefault.properties.

That file can exist in one of two places in the OS/400 Integrated File System (IFS): your user home directory or the Java home directory. Your user home directory is qualified in your user profile, so use the Display User Profile (DSPUSRPRF) command to see what yours is set to. (Here's a hint: It defaults to a directory of your profile name underneath the /home directory.) The Java home directory is /QIBM/UserData/Java400/.

The easiest way to modify the SystemDefault.properties file in your AS/400 IFS (or, if it doesn't yet exist, create it) is to use the Edit File (EDTF) command:

EDTF '/home/Denoncourt/SystemDefault.properties'

Then, add this entry:

java.version=1.3

First, Java looks to the Java command options. Then, it looks to the user home SystemDefault.properties file. Next, it looks to the Java home SystemDefault.properties file. Finally, it looks to an environment variable for the setting of the JDK.

Note that you can also create a SystemDefault.properties in the /etc directory so the default JDK is set for everyone rather than for an individual, as when you place the properties file in the user's home directory.



BLOG COMMENTS POWERED BY DISQUS