简体   繁体   English

如何在Eclipse中使用Java 8文档

[英]How to use Java 8 docs in Eclipse

I'm having issues seeing API documentation for Java 8 in Eclipse. 我在Eclipse中看到Java 8的API文档时遇到了问题。 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 如果我将鼠标移到Calendar那么我会看到所有正确的文档,但是如果我将鼠标悬停在getInstance()我会收到一条消息

Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc. 注意:此元素没有附加源,并且在附加的Javadoc中找不到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. 我将rt.jar的Javadoc位置设置为http://docs.oracle.com/javase/8/docs/api/ ,我也尝试下载文档的本地副本并遇到同样的问题。 Changing the link to the Java 7 docs fixes the problem I'm having. 更改Java 7文档的链接可以解决我遇到的问题。

Eclipse seems to be using the wrong anchor style (not sure how else to word it) when looking for methods. 在寻找方法时,Eclipse似乎使用了错误的锚样式(不确定如何用它来表达它)。 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 当它查找getInstance()方法时,它检查http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance() ,但它应该检查

Calendar.html#getInstance-- Calendar.html#getInstance--

All brackets and commas seem to have been replaced by hyphens in the Java 8 doc links. 所有括号和逗号似乎都被Java 8 doc链接中的连字符所取代。 I experienced this problem with Eclipse 4.3 (Kepler), 4.3 with the patches for Java 8, and now with 4.4 (Luna) 我在Eclipse 4.3(Kepler)中遇到过这个问题,4.3用Java 8补丁,现在用4.4(Luna)

Is there a way to update Eclipse so that it properly displays the docs in the mouse over tooltips? 有没有办法更新Eclipse,以便它在工具提示中正确显示鼠标中的文档?

Setting the installed JRE to JDK 8 fixes your problem. 将已安装的JRE设置为JDK 8可以解决您的问题。

This can be done by going to 这可以通过去做

Window -> Preferences -> Java -> Installed JRE -> Edit -> Directory and selecting the JDK 8 installation folder

Step 1: Windows -> Preference -> Java -> Installed JRE -> Edit -> Directory (Specify the JDK directory (and not JRE)) 第1步:Windows - >首选项 - > Java - >已安装的JRE - >编辑 - >目录(指定JDK目录(而不是JRE))

Step 2: Click "Restore Defaults" 第2步:点击“恢复默认值”

Step 3: Click OK 第3步:单击“确定”

This worked for me in Ubuntu 14.10, Eclipse Kepler using openjdk-8 这对我来说在Ubuntu 14.10,Eclipse Kepler中使用openjdk-8

Window > Preferences > Java > Installed JREs > Click on your java-8-openjdk > Edit 窗口>首选项> Java>已安装的JRE>单击您的java-8-openjdk>编辑

For /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar: 对于/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:

set Source attachment to: 将源附件设置为:

/usr/lib/jvm/java-8-openjdk-amd64/src.zip

set Javadoc location to: 将Javadoc位置设置为:

file:/usr/share/doc/openjdk-8-doc/api/

NOTE: If you don't already have the openjdk-8 java doc, install: 注意:如果您还没有openjdk-8 java doc,请安装:

sudo apt-get install openjdk-8-doc

and for the source: 并为来源:

sudo apt-get install openjdk-8-source

I had the same problem. 我有同样的问题。 I did set the installed JRE to be JDK8. 我确实将已安装的JRE设置为JDK8。 Still wasn't working until I clicked "edit" on the jre (under 'Installed JREs') then then clicked "Restore Defaults". 直到我在jre上单击“编辑”(在“已安装的JRE”下)然后单击“恢复默认值”之后仍然无法工作。 Then it started working... Looking at each jar in that list I see it sets "Source attachement" and not "Javadoc location". 然后它开始工作......看看该列表中的每个jar我看到它设置“Source attachement”而不是“Javadoc location”。 Seems to work. 似乎工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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