Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Java 8 docs in Eclipse

I'm having issues seeing API documentation for Java 8 in Eclipse. Here's an example of the problem I'm having

Calendar myCalendar = Calendar.getInstance();

If I mouse over Calendar then I see all the correct documentation, however if I mouse over getInstance() I get a message saying

Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc.

I have the Javadoc location for rt.jar set to http://docs.oracle.com/javase/8/docs/api/, I've also tried downloading a local copy of the docs and had the same problem. Changing the link to the Java 7 docs fixes the problem I'm having.

Eclipse seems to be using the wrong anchor style (not sure how else to word it) when looking for methods. When it looks for the getInstance() method, it checks http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance(), but it should be checking

Calendar.html#getInstance--

All brackets and commas seem to have been replaced by hyphens in the Java 8 doc links. I experienced this problem with Eclipse 4.3 (Kepler), 4.3 with the patches for Java 8, and now with 4.4 (Luna)

Is there a way to update Eclipse so that it properly displays the docs in the mouse over tooltips?

like image 373
rosscarrothers Avatar asked Mar 25 '14 17:03

rosscarrothers


People also ask

How do I use Javadoc in Eclipse?

Step 1 − Open eclipse, select the option Project →Generate Javadoc. Step 2 − Select the javadoc.exe file from the bin folder of java installation directory, select the destination folder for the generated java doc and select Next. finish button.

Can we use Java 8 in eclipse?

Eclipse requires Java 11 to run, but supports also older versions (starting with Java 1.1, up to Java 15, and of course Java 8). You can target any Java version you want if you install the proper runtime. Just because eclipse itself requires Java 11 doesn't mean it can't compile for lower versions.

How do I check my Javadoc in Eclipse?

Window->Preferences->Java->Installed JREs. Once you have that set up, you might be interested in the Javadoc view: Window->Show View->Javadoc.

How do I download Javadoc in Eclipse?

Moreover, in Eclipse you can just go to Preferences -> Maven (No subcategory). There, you can check "Download artifact Sources/JavaDocs".


2 Answers

Setting the installed JRE to JDK 8 fixes your problem.

This can be done by going to

Window -> Preferences -> Java -> Installed JRE -> Edit -> Directory and selecting the JDK 8 installation folder
like image 144
jmj Avatar answered Sep 20 '22 22:09

jmj


Step 1: Windows -> Preference -> Java -> Installed JRE -> Edit -> Directory (Specify the JDK directory (and not JRE))

Step 2: Click "Restore Defaults"

Step 3: Click OK

like image 43
Prateek Avatar answered Sep 22 '22 22:09

Prateek