I'm trying to get javadocs for my classes directly from console with following code javadoc -sourcepath ./src/main java.packageName
. Those classes have dependencies on external libraries (e.g junit.framework
). This code is easy to compile from IntelliJ IDEA or via mvn clean install
, but when I'm trying to create javadocs I face the problem that external classes and packages cannot be recognized (e.g. error: package junit.framework does not exist
). Same problem occurs with JDK 8 as well, but there those are warnings and javadocs are generated anyway.
There are two approaches you could take to get the javadocs to build from the command line:
Add the maven-javadoc-plugin to your project's POM file so that you can use (for example) mvn javadoc:javadoc
to generate the javadocs. See the plugin documentation for more details.
Run javadoc
directly with the correct command-line arguments.
I suspect that there are a couple of reasons why your current attempt is failing:
You appear to be generating javadocs for your src/test
tree. That may be unintentional.
(If the above "error: ..." is coming from the src/main
javadoc generation, I'm puzzled why your src/main
source code is referring to the junit.framework
package. It could do, but production code wouldn't normally depend on a test framework.)
You need to use a -classpath
option to tell javadoc
where to find the external libraries are.