Search code examples
javajavadoc

Include external jars when compiling javadoc


As probably a lot of projects we currently use some external jars like apache commons. Now when compiling javadoc and just pointing it at our sources with this command: javadoc -version -author -sourcepath project/src -d . -subpackages . -encoding "ISO-8859-1" you get errors like

OurFTPClient.java:15: error: package org.apache.commons.net.ftp does not exist.

Now from a bit of googling (actually hard to find, because you get lots of answers for problems putting javadoc into a jar) i gathered i just have to modify the javadoc command like this: javadoc -version -author -sourcepath project/src -d . -subpackages . -encoding "ISO-8859-1" -classpath project/jars/*. This goes through completely fine on windows with oracle JDK8. But under linux and OpenJDK8 this errors with

javadoc: error - Illegal package name: "project/jars/commons-codec-1.10.jar".

If anyone has any idea why that happens and if this is a bug in OpenJDK or not, and how to workaround it, i would be really grateful!


Solution

  • The answer was actually pretty easy, just not very intuitive. You have to put quotation marks around the classpath to work under Linux (i presume, not entirely sure if it is OpenJDK related).

    The final command would then look like this: javadoc -version -author -sourcepath project/src -d . -subpackages . -encoding "ISO-8859-1" -classpath "project/jars/*"