javanetbeansjavadocnetbeans-10

How to stop Javadoc from using fully qualified name?


I'm using the Javadoc tool to document some code, and the results uses fully qualified names for system classes, such as java.lang.String. Is there a way to stop that specifically for classes in the java.* and javax.* heirarchy?

For example, a method definition like this:

    * @param field String to write.
    * @throws IOException If the underlying stream throws an exception.
    */
   public void writeField( String field ) throws IOException {
      // etc.

Produces Javadoc output like this:

writeField

public void writeField​(java.lang.String field) throws java.io.IOException

    ...etc.

Parameters:
    field - String to write.
Throws:
    java.io.IOException - If the underlying stream throws an exception.

I'd like the reference to java.lang.String to be just String, and the reference to java.io.IOException likewise to be just IOException.

Any ideas?


Edit and update re. the accepted answer below:

In NetBeans 10, what I did to fix this was go to the Project view, then switch to Files view. Then in the project files, locate nbproject/project.properties and open that file (right click, choose open).

In the properties view, scroll down on the left until you see javadoc.additionalparam. Then add the following to the right side of that property (in my case its value was empty) -link https://docs.oracle.com/en/java/javase/11/docs/api/

Then save (control-S) the file and build. The Javadocs now look how I wanted. Thank you Slaw!


Solution

  • Javadoc outputs the fully qualified name if it can't link to the class/method/etc. For it to just output the simple name you must link to the external Javadoc. This is done via the -link <url> command line option of the javadoc tool. To link to SE classes (i.e. java.* and javax.*), one option is to use:

    javadoc -link https://docs.oracle.com/en/java/javase/11/docs/api/ [...]
    

    Where [...] is the rest of the command line. You can change the URL to point to a different version of Java (e.g. Java 8 instead of Java 11).

    There's also a -linkoffline <url1> <url2> option.

    Note: I believe both options are provided by the "Standard doclet". If not using the standard doclet these options may not be available or may work differently.