如何让 Java API Javadocs 显示在 Ubuntu 的 Eclipse 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1678278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Java API Javadocs to show up in Eclipse in Ubuntu
提问by Manuel Aráoz
I'm here again with a docs question. At my university, when using Eclipse, when placing the cursor over a Java API method name (for example: .size() ), I get very nice documentation about it.
我带着一个文档问题再次来到这里。在我的大学,当使用 Eclipse 时,将光标放在 Java API 方法名称(例如: .size() )上时,我得到了关于它的非常好的文档。
Here at home I get
在家里我得到
Note: This element neither has attached source nor attached Javadoc
and hence no information could be found.
Any quick and simple apt-get fix? Thanks in advance!!!!
任何快速简单的 apt-get 修复?提前致谢!!!!
回答by Pascal Thivent
Go to your JRE settings (Window > Preferences > Java > Installed JREs), select your current, then Editit and set the Source Attachmentfor rt.jar
.
去你的JRE设置(窗口>首选项> Java的>安装的JRE),选择您的当前,然后编辑并设置了源代码连接的rt.jar
。
You might have to install the sun-java6-source
or openjdk-6-source
packages depending on what you are using.
根据您使用的内容,您可能必须安装sun-java6-source
或openjdk-6-source
软件包。
For the Sun JVM, sources will end up in /usr/lib/jvm/java-6-sun-1.6.0.15/src.zip
.
对于 Sun JVM,源代码将以/usr/lib/jvm/java-6-sun-1.6.0.15/src.zip
.
PS: I'd suggest to use Sun JDK and to set it as default with sudo update-alternatives --config java
but this is more a side note.
PS:我建议使用 Sun JDK 并将其设置为默认值,sudo update-alternatives --config java
但这更像是一个旁注。
回答by matt b
In Preferences
, make sure that under Installed JREs
you are using a JDK and not a JRE.
在 中Preferences
,确保Installed JREs
您使用的是 JDK 而不是 JRE。
I don't think that the JRE installs include the source attachment.
我认为 JRE 安装不包括源附件。
回答by Adrian Park
Try out apt-get install eclipse-source
.
试试看apt-get install eclipse-source
。
回答by Wasim Hossain
The following procedure will enable Java documentation to be available in Eclipse when you hover over some Java class. Download the Java Documentation (this is for version 6) from http://www.google.co.in/url?sa=t&source=web&ct=res&cd=4&ved=0CC0QFjAD&url=https%3A%2F%2Fcds.sun.com%2Fis-bin%2FINTERSHOP.enfinity%2FWFS%2FCDS-CDS_Developer-Site%2Fen_US%2F-%2FUSD%2FViewProductDetail-Start%3FProductRef%3Djdk-6u10-docs-oth-JPR%40CDS-CDS_Developer&ei=T-z3S87CAYuyNq3UweAF&usg=AFQjCNH54wkg50p7PJGmv6dEJd0zxXTGRA&sig2=Pv8-OZ7ZQEAsh89kUFhvUwThis is a zipped file jdk-*-docs.zip ( * indicates the version number, for e.g., 6u18 which implies Java Version 6.18). Open Eclipse. Click on Window > Show View > Javadoc Right click on the Javadoc console. Select Open Input. Click "Change Attached Source". Select "External File". Navigate to the directory in which jdk-*-docs.zip exists. Open it. And there you have it - the entire documentation available to you at your fingertip(mousetip?).
当您将鼠标悬停在某个 Java 类上时,以下过程将使 Java 文档在 Eclipse 中可用。从http://www.google.co.in/url?sa=t&source=web&ct=res&cd=4&ved=0CC0QFjAD&url=https%3A%2F%2Fcds.sun.com%下载 Java 文档(适用于版本 6)2Fis斌%2FINTERSHOP.enfinity%2FWFS%2FCDS-CDS_Developer站点%2Fen_US%2F-%2FUSD%2FViewProductDetail启动%3FProductRef%3Djdk-6u10中-文档-OTH-JPR%40CDS-CDS_Developer&EI = T-z3S87CAYuyNq3UweAF&USG = AFQjCNH54wkg50p7PJGmv6dEJd0zxXTGRA&SIG2 = PV8 -OZ7ZQEash89kUFhvUw这是一个压缩文件 jdk-*-docs.zip(* 表示版本号,例如,6u18 表示 Java 版本 6.18)。打开日食。单击窗口 > 显示视图 > Javadoc 右键单击 Javadoc 控制台。选择打开输入。单击“更改附加源”。选择“外部文件”。导航到 jdk-*-docs.zip 所在的目录。打开它。有了它 - 整个文档都在您的指尖(鼠标提示?)。
回答by Vijay Tyagi
- Download Java sourece. i get it from http://download.java.net/openjdk/jdk8/
- 下载 Java 源代码。我从http://download.java.net/openjdk/jdk8/得到它
2.Go to Window > Preferences > Java > Installed JREs
2.转到窗口>首选项>Java>已安装的JRE
Select the installed JDK and double click on it, a edit JRE window will get open.
选择已安装的 JDK 并双击它,将打开一个编辑 JRE 窗口。
select rt.jar click add source and and select the patch where you have downloaded java source in step 1.
then exit by clicking OK/ Finish
选择 rt.jar 点击添加源,然后选择您在步骤 1 中下载的 java 源的补丁。
然后单击确定/完成退出