我在 Eclipse 中查看 Java 8 的 API 文档时遇到问题。这是我遇到的问题的示例
Calendar myCalendar = Calendar.getInstance();
如果我将鼠标悬停在 Calendar
上,那么我会看到所有正确的文档,但是如果我将鼠标悬停在 getInstance()
上,我会收到一条消息说
Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc.
我将 rt.jar 的 Javadoc 位置设置为 http://docs.oracle.com/javase/8/docs/api/ ,我也试过下载文档的本地副本,但遇到了同样的问题。更改指向 Java 7 文档的链接可以解决我遇到的问题。
在寻找方法时,Eclipse 似乎使用了错误的 anchor 样式(不知道怎么说)。当它查找 getInstance()
方法时,它会检查 http://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getInstance() , 但它应该检查
Calendar.html#getInstance--
在 Java 8 文档链接中,所有括号和逗号似乎都已被连字符取代。我在 Eclipse 4.3 (Kepler)、带有 Java 8 补丁的 4.3 和现在的 4.4 (Luna) 上遇到过这个问题
有没有一种方法可以更新 Eclipse,使其在鼠标悬停在工具提示上时正确显示文档?
最佳答案
将已安装的 JRE 设置为 JDK 8 可以解决您的问题。
这可以通过转到
Window -> Preferences -> Java -> Installed JRE -> Edit -> Directory and selecting the JDK 8 installation folder
关于java - 如何在 Eclipse 中使用 Java 8 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22642230/