IBM Support

Support of the "java.class.path" and "os400.class.path.tools" Java Properties with the IBM Technology for Java "javac" Utility

Troubleshooting


Problem

A "java.lang.NoClassDefFoundError: com.sun.tools.javac.Main" might occur when executing the "javac" IBM Technology for Java utility.

Symptom

Exception in thread "main" java.lang.NoClassDefFoundError: com.sun.tools.javac.Main
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main                    at java.net.URLClassLoader.findClass(URLClassLoader.java:600)              
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:786)                     at java.lang.ClassLoader.loadClass(ClassLoader.java:760)                  
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)          
at java.lang.ClassLoader.loadClass(ClassLoader.java:741)

Cause

The /QOpenSys/QIBM/ProdData/JavaVM/jdkXX/XXbit/lib/tools.jar file is not included in the Java Classpath value.

Environment

IBM i; IBM Technology for Java VM

Resolving The Problem

When executing the "javac" utility from the IBM i QShell interpreter command line, you might encounter the following error message.

Exception in thread "main" java.lang.NoClassDefFoundError: com.sun.tools.javac.Main
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main                    at java.net.URLClassLoader.findClass(URLClassLoader.java:600)              
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:786)                     at java.lang.ClassLoader.loadClass(ClassLoader.java:760)                  
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)          
at java.lang.ClassLoader.loadClass(ClassLoader.java:741)

The above error message will occur when the /QOpenSys/QIBM/ProdData/JavaVM/jdkXX/XXbit/lib/tools.jar file is not included in the class path for the IBM i JDK currently being used by the "javac" utility.

In order to understand the cause and resolution of this issue better, IBM would like to provide further explanation on the support of the "os400.class.path.tools" and "java.class.path" Java properties.

os400.class.path.tools

The "os400.class.path.tools" Java property is not supported with the IBM Technology for Java VM. This property was previously supported by the Classic JDK version at IBM i 6.1 and earlier. Setting the "os400.class.path.tools=1" property will NOT prepend the J2SE specific tools file (/QOpenSys/QIBM/ProdData/JavaVM/jdkXX/XXbit/lib/tools.jar) to the "java.class.path" property as the IBM Knowledge Center documents.

As a result, setting the "os400.class.path.tools=1" property will NOT resolve the above "java.lang.NoClassDefFoundError: com.sun.tools.javac.Main" error message.

java.class.path

As for the "java.class.path" property, this property is still supported by most IBM Technology for JDK utilities, but doesn't work well with the javac utility.  Since the "java.class.path" property overrides the Java class path, it will remove the /QOpenSys/QIBM/ProdData/JavaVM/jdkXX/XXbit/lib/tools.jar file from the class path value, which is required to exist in the class path for the javac JDK utility to function correctly. 

As a result, the "java.class.path" property can be used with the javac utility, but the user would need to include the /QOpenSys/QIBM/ProdData/JavaVM/jdkXX/XXbit/lib/tools.jar file path in the "java.class.path" value in order for the javac JDK utility to function correctly.  IBM recommends using the CLASSPATH environment variable or the "-cp or -classpath" command line options as better methods to set the Java classpath with the javac utility.

i.e. java.class.path=/QOpenSys/QIBM/ProdData/JavaVM/jdk80/32bit/lib/tools.jar:<rest of classpath>:

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHpAAM","label":"Java Development Kit-\u003EJDK 8"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Document Information

More support for:
IBM i

Component:
Java Development Kit->JDK 8

Software version:
All Versions

Operating system(s):
IBM i

Document number:
666823

Modified date:
21 April 2025

UID

nas8N1021159

Manage My Notification Subscriptions