Netbeans 11 Javadoc Not Appearing? - java

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.
Search your Java version package:
sudo apt-cache search java* | grep jdk
Install the version you need (I have installed two of them):
sudo apt-get install openjdk-8-doc openjdk-11-doc
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.
Set that path in the platform configuration of Netbeans.
Done with Ubuntu 20.04 and Netbeans 12. Hope it helps other people.

Related

What should I do if I can only see jdk 17 in my JavaVirtualMachine path and not the other jdk's?

My ls /Library/Java/JavaVirtualMachines tells me I have multiple jdks installed but the path from the finder only gives me jdk 17.0.2.
Due to this, I am not able to provide the jdk 16's path in my Netbeans to add another jdk platform to test and run my project.
Any help would be great :) !!!
Finder doesn't hide JVMs for funsies. If ls says they exist, they exist. Try as a trick navigating to one of the JDKs you can't find with cd, and then typing open . on the command line. What happens then? Alternatively, hit CMD+K (go to folder) and paste a full folder. Then just drag from there to the netbeans dialog.
NB: For the future / for others answering this question, you might want to mention in your question that you're using MacOS, or tag it with macos.

Correct Java dependencies installed for eclipse ADT development

I have eclipse and the ADT bundle correctly installed on my home PC, and tried to install it on my laptop so I can work on my projects on the go. However, I either didn't set the java paths correctly, or installed them in the wrong place, because I can't get a default project to load without errors.
I have correctly:
-Installed the ADT bundle and launched eclipse without errors
-Created a workspace
-Correctly Installed both the jre8 and jdk1.8.0_05 in the location C:\Program Files\Java
I am very new to Android development, and I feel like I was lucky to set up the Java dependencies correctly on my home PC, no such luck this time from what the error look like...
However, when I try to make a basic "Hello world" project, I immediately get the following error:
The container 'Android Dependencies' references non existing library 'C:\Users\userName\workspace\appcompat_v7_3\bin\appcompat_v7_3.jar'
I have tried adding the library, by checking build configurations, but I don't understand fully whats going on to correctly solve the problem. Here is my workspace:
And lastly, I tried checking the build configurations to see that the libraries are, in fact, missing. Or something like that. I am not sure if I should just try to reinstall java and the jdk.
Build configuration:
Anyway, I'm not sure what I deleted, misplaced, uninstalled, or didn't install, but if anyone could point me to a solution I would be very grateful. If anyone has any other questions on my setup I will try and be as thorough as possible. Thank you!
In my experience I have had issues like this if not running eclipse as Administrator. Make sure that you aren't being blocked here.
EDIT: Please note Chris Stratton's concers regarding running an IDE as Administrator, as seen in the comments below.
EDIT 2: In my more recent experience, I have noticed that if I installed the SDK by copying and pasting the contents of the downloaded, compressed, folder to a destination rather than extracting it first, I would be required to run as Administrator. If this is the case, delete the SDK that you copied out of the compressed folder and simply extract the contents of the downloaded compressed folder. I am running Windows 7 so it is likely that this applies to all Windows 7 and 8 OS's.
In another case, I have also seen issues like this if the JRE is installed second rather than first. In this case, a reinstall of the SDK is probably all that is required.

New computer, broken Eclipse

I received my new computer friday and after moving over all of my development projects, my Eclipse "hover" popups have quit working. What I mean is usually when I hover over an element/method/etc... , a small window with the javadoc info will pop up telling me parameters, and a description of the method. Now it just says:
Note: The Javadoc for this element could neither be found in the attached source nor the attached Javadoc.
I've already seen this SO post and tried it. Although I will say there are 15 different packages when you go into preferences>java>installed jre's>edit. All point to an http:// address for the docs.
Also the Android documentation I installed doesn't pull up either (which is what I'm developing for).
Is this with your standard Java classes/methods/etc. or for custom/Android code? I think your problem is because of your installed JRE. You need to download the Java SE 6 SDK from here. The JDK has all of the standard Java classes' source files. Once you have it installed, in Eclipse, go to
'Window'->'Preferences'->'Java'->'Installed JREs'.
Click the 'Add...' button and select 'Standard VM'.
In the 'JRE home' field put "C:\your\path\to\java\jdk1.6_xYourVersionx". It will automatically populate the 'JRE name' field and import all of the necessary jars.
Click 'Finish' and then 'OK'.
If it's a problem with some nonstandard Java code, make sure that you've downloaded the source code. Then,
Right-click on your project and go to 'Build Path'->'Configure Build Path...'.
Select the 'Libraries' tab and expand the entry for your jar file. There should be a sub-entry 'Source attachment: (None)'.
Select it and click the 'Edit...' button and put in your path to the source code.
Click 'OK' and 'OK'.
NOTE: If you've already installed the JDK, you can edit your current JRE to point to the jdk folder instead of the jre folder i.e. "C:\Java\jdk1.6.0_xx" instead of "C:\Java\jre6".
2nd NOTE: Your bit version of Java must match your bit version of Eclipse, so 32-bit Eclipse requires a 32-bit Java, etc.

Java Debugging with Eclipse

I'm trying to debug a program that calls a function in the HashSet class, but I get a message saying: Source not found. I know this is something with not finding the library files. Please, can someone guide me to how I can set it up? Which library files should it be pointing to?
Thank you very much for any pointers.
Finally got around to doing this awhile ago and I love it.
First you need to download the Java source. I got mine here (look for "Java SE 6 JDK Source Code"): http://www.oracle.com/technetwork/java/javase/downloads/index.html. Download that and stick it somewhere on disk that you can find easily. Keep in mind that the JAR you download has to actually be "installed" somewhere via you agreeing to a license agree (extract it with jav xvf jarname.jar and check the README it contains).
For any JAR file on your CLASSPATH in Eclipse, you can add a source attachment to it to point to its source code. The easiest thing to do is bring up the Package Explorer view. Underneath your project, you should see an item for your Java Runtime Environment (JRE) (mine is called "JRE System Library [JavaSE-1.6]"). Click on the expansion arrow for that and you'll see a list of JARs.
Most all of the Java classes you'll care about viewing are stored in "classes.jar". Right-click on that JAR and select "Properties". In the left hand menu, select "Java Source Attachment". On the right side, click "External Folder" and find the source code that you downloaded and installed and put that folder into the "Location path" field. Hit "Apply" and "OK".
Now you should be able to right click on any built-in Java class in your code and use the "Open Declaration" command or when debugging you will now step into the Java source.
It's a great capability to have. Enjoy!
HashSet is in JRE Package, so you can download JDK source and attach it into eclipse.
An other way, when you can not find out the source package, you can use JD-Decompiler
which has eclipse plugin to decompile your class, it work and show most like original source file.
Choosing a JDK instead of JRE for the runtime environment worked for me!
NOTE:Make sure you have a JDK installed and not only JRE before proceeding.
Remove the current system JRE library:
Right Click project -> properties -> Libraries -> Remove current JRE Library.
Add other installed library to your project:
In the current dialogue box, click "add library". by default JRE system library is selected, if not, select it and click next. now select "Alternate JRE" and click "Installed JRE". In the new dialogue box, click search and provide the path to your installed Java environments.
Finalize
Select an installed JDK, and click OK. Click FINISH and again OK to proceed.
Abdul,
The best way is as the others explained to download the sources and attach them in the eclipse.
The EASIEST way would be installing the java decompiler (JAD). Take a look at http://jadclipse.sourceforge.net/install.html. Its explained there in 4 super simple steps :)

Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files

I'm a Java noob (but have been programming for 25+ years, and have worked with OO languages from day 1).
All of a sudden I started getting this error:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Not sure what caused this condition, and not sure what Java's asking me to do. I'm working in the NetBeans IDE. The last thing I attempted to do is add some binary (image) resources to my project.
In my case the JDK setup in Netbeans was fine. It was just one of those strange Netbeans issues that come out of nowhere.
My fix was:
Clear the Netbeans Cache i.e. delete the folder:
C:\Users\\AppData\Local\NetBeans\Cache\
It means you haven't told netbeans where your Java 1.6 installation is. Go into settings, add the JDK (JDK->Add->New), and select the directory above 'bin' for your JDK16.
This error can occur at two scenarios:
Right click your netbean project -> Properties -> Libraries
After select Libraries , right panel on top you can see "Java Platform" combo box. This Jave Platform is missing for your project. You need to add using Manage Platforms bottom beside Jave Platform combo box.
Even thought scenario (1) is correct it can happen. Because your project has reference to another netbean project in your Libraries. This reference project is missing Jave Platform.
I have Linux in my office and Mac in Home and this problem is frequently when I share projects in github, I solve it removing the build directory and doing clean and build.
Right click on project - Properties - Libraries - Select the correct jdk version from the Java Platform combobox.
NetBeans bug
If your project depends on other projects, open and clean build all of them(that fixed it for me).
Most likely cache-related stuff. Clean up NB cache as suggested by someone before
You should remove the files under private folder in the nbproperties folders.
for me any recommended way early didn't helped, but changing in project Properties -> Source/Binary format to JDK 7, Save than change back to JDK 8 fixed this error

Categories