Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed sun-java6-jdk and sun-java6-jre (and likely other related java6 packages such as fonts) for a project running on a Ubuntu 11.04 server distribution. Our project programmatically calls Javadoc from within our running executable. To do so, we obviously need to know the location of the tools.jar file which is part of the JDK distribution, but not the JRE distribution. The packages were installed into /usr/lib/jvm/java-6-sun- and there are bin and other directories under the two areas (JDK/JRE) which provide the various standard binaries.

Whenever we execute a java program (via the java binary), the internal java.home variable seems to overwrite any JAVA_HOME environment variable provided. We have concluded that the binary thus derives its java.home from the path of the binary. The java binary under the jdk really is a link to the jre version. Thus, no matter which one you 'execute', you are always getting the jre version, and thus the java.home directory is defined to be /usr/lib/jvm/java-6-sun-

As such, any running executable can not seem to find the tools.jar file, and even passing the -cp /usr/lib/jvm/java-6-sun- option does not help. We're hoping that someone can help shed some light on how we can correctly access the tools.jar file enabling us to correctly be able to call the method.

Example execution:

java -cp /usr/lib/jvm/java-6-sun/lib/tools.jar -jar comtor.jar -sourcepath .

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main
    at comtor.Comtor.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 1 more
share|improve this question
up vote 1 down vote accepted

Well, it's a hack, but we ended up copying the tools.jar file into the jre/lib/ext directory as if we were installing a 3rd party jar file as an extension. This seems like an unnatural action and that we should be doing something on the command line via the -cp option (tried it and it failed), or through an environment variable (tried that too and it failed too).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.