Fixing scaladoc error “Cannot load the doclet class”

When running scaladoc with a custom generator, you can get the following error message:

error: Cannot load the doclet class com.garysieling.MicroformatScalaDoc 
(specified with -doc-generator): java.lang.ClassNotFoundException: 
com/garysieling/MicroformatScalaDoc. 

Leaving the default settings will generate the html version of scaladoc.

Unfortunately there are seven or eight different classpath arguments to scaladoc, which makes it tricky to execute. The key argument is “-toolcp”.

If you’re writing a custom doclet, you need to depend on the build output of your project – with sbt this will be in the target/scala-2.11/classes:

export CLASSPATH=./target/scala-2.11/classes
 
echo $CLASSPATH
 
scaladoc -verbose \
         -doc-generator com.garysieling.CustomScalaDoc \ 
         -toolcp $CLASSPATH \
         src/main/scala/com/garysieling/microformat.scala

Interested in Scala? I send out weekly, personalized emails with articles and conference talks. Click here to see an example and subscribe.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *