javaintellij-ideajavadocdoclet

Why can't i import the jdk.javadoc.doclet package?


I wanted to make a custom doclet for JavaDoc and i initially tried to use the com.sun.javadoc package for this application. I was successfully able to create a doclet and use it with JDK8, but doing this with JDK12 gives me a warning that this class is deprecated and would be soon out of support.

I tried the same doclet with JavaDoc on another computer with OpenJDK15 (running java --version gave me the following output:)

openjdk 15.0.1 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

and it is really out of support :( I could not use it and it gave me a message saying that this doclet is not supported.

After some research, i found that the new jdk uses the jdk.javadoc.doclet API to create doclets. i created a basic doclet using the above class that actually does nothing, just implemented all methods and tried to compile, but the compiler gave me an error saying that package jdk.javadoc.doclet does not exist.

I use IntelliJ as my IDE but it doesn't show any error through it's IntelliSense. IntelliJ believes that the package exists and even provides me code highlighting for the methods in the classes of that package.


Solution

  • The solution was pretty simple. I just needed to make the code modular (i.e., i needed to add a module-info.java file in my project) and add requires jdk.javadoc line to it to make the code running without any errors.