简体   繁体   中英

Netbeans 11 Javadoc Not Appearing?

I have a question very similar to Javadocs are not appearing on Apache netbeans for java 10 in the sense that I can't seem to add javadoc support to my Apache Netbeans 11 release, or the maven project that I'm working on.

Here is the overview that I have: 平台

As you can see, the javadoc is added in the URL section, but it does not appear in the code editor, even after a restart.

The URL I added: https://docs.oracle.com/en/java/javase/11/docs/api/index.html

But this doesn't work.

How can I resolve this?

Whilst Netbeans 11 runs well with Ubuntu 18's apt packet "openjdk-11-jdk", when it comes to NB's source-editor's pop-up-Javadoc and "show Javadoc" function (which opens an external browser), both NB functions don't work on a standard Ubuntu installation.

Because NB's Javadoc functions seem so dislike the "openjdk-11-jdk" packet's file structure in "/usr/lib/jvm/java-11-openjdk-…" which is slightly different to the one from the downloadable Openjdk11 zip bundle.

Here's the solution to make both functions work:

  • Download the Openjdk11 zip bundle for Linux from the Openjdk's website: https://jdk.java.net/archive/
  • Unzip it, so that its content is in a folder, like for example "openjdk11"
  • In NB go to the menu "Tools → Java platforms". Add a new platform and select the unzipped folder (openjdk11 for example). NB finds out the correct sources folders inside the src.zip file.

Finally in your NB project property, change in "Libraries" the "Java Platform" to your newly added Openjdk11 platform, and now NB's pop-up-Javadoc works again.

To also have NB's "show Javadoc" functionality, do this additional step please:

  • Download Oracle's Javadoc11 zip file and unzip it.
  • Now go to NB's "Java platform" dialogue again and. In the previously added platform "Openjdk11" go to the third tab named "Javadoc" and add as folders all the "java*" subfolders inside the "doc/api/" folder.

That's it. Hope it helps.

Btw, now NB still runs inside Ubuntu's installed Openjdk11 JVM (from the paket "openjdk-11-jdk") and will get apt-automatic updates, however your projects use the unzipped JVM to run. This is no big deal however, since NB always uses a new instance of its used JVM or of the project's JVM to run a project.

I've yet to see somebody who managed to add Javadoc 11 to Netbeans 11.

But there's a work-around which seems to work for many JDK classes, but not for all. If anybody knows how to solve the problem for all JDK classes, please say so, thanks.

Here's the workaround, doing well under Ubuntu 18 Linux with Openjdk11 from the Ubuntu repository, and probably also under other platforms:


Firstly it's strange how we have to add the Javadoc at all. In NB's menu Tools → Java Platforms there's a tab Sources and Javadoc .

1) I tried to use the tab Javadoc first, and had to add all the folders beginning with "java." from the main folder "javadoc/api/" from an unzipped Javadoc11 bundle. This way some JDK functions show the correct Javadoc pop-up help, however many functions just show an empty space, like for example when in Netbeans I enter:

BigInteger big;
big. _

Then the pop-up comes and lists all BigInteger functions but their Javadoc is empty each.

So I tried another approach:


2) From the same NB menu Tools → Java Platforms in the tab Javadoc I removed all entries, and used the other tab Sources where I added all the folders beginning with "java." from an unzipped Java11 source bundle (file src.zip).

This way for many more JDK classes and functions their pop-up window works fine, like the mentioned BigInterger one.

However for certain classes from the java.sql package and probably from others, too, I can't make it to work. For example I enter in NB:

java.sql.Statement stat;
stat. _

Then I get a pop-up listing all functions, but for many there's a message Javadoc not found in the pop-up window. Like these functions:

stat.addBatch(…)
stat.execute(…)
stat.executeUpdate(…)
etc.

For the following functions however the pop-up window shows the correct Javadoc:

stat.cancel(…)
stat.close(…)
stat.executeBatch(…)
etc.

If you are on an Ubuntu or Debian based OS, in the apt repository there is an specific package for the documentation separated from the JDK that you need to install. Once done, you only need to search for the api folder inside of the docs and set it in the platforms configuration.

  1. Search your Java version package:
sudo apt-cache search java* | grep jdk
  1. Install the version you need (I have installed two of them):
sudo apt-get install openjdk-8-doc openjdk-11-doc
  1. Search for the api folder, I have found it for OpenJDK-11 in /usr/lib/jvm/java-11-openjdk-amd64/docs/api and for OpenJDK-8 in /usr/lib/jvm/java-8-openjdk-amd64/docs/jdk/api. The location will depend on where your JDK is installed, but should be a quite similar path if you have installed it with apt.

  2. Set that path in the platform configuration of Netbeans.平台经理的形象

Done with Ubuntu 20.04 and Netbeans 12. Hope it helps other people.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM