Eclipse 中的 Java API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1292611/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 07:51:48  来源:igfitidea点击:

Java API in eclipse

javaeclipseapi

提问by

Im new to eclipse , can anybody tell me how to use an JAVA API in eclipse. or share any sample Java API.

我是 eclipse 的新手,谁能告诉我如何在 eclipse 中使用 JAVA API。或共享任何示例 Java API。

Yes, how to use JavaDoc file in eclipse.

是的,如何在 Eclipse 中使用 JavaDoc 文件。

回答by Rich Seller

I'm not clear exactly what you're after, but if you create a new Java project, you will have access to the JRE system library's contents as a classpath container.

我不清楚您到底要做什么,但是如果您创建一个新的 Java 项目,您将可以访问 JRE 系统库的内容作为类路径容器。

File->New->Java Project, enter project name, select OK.

File-> New-> Java Project,输入项目名称,选择OK

You'll then be able to create new classes and access the Java classes.

然后,您将能够创建新类并访问 Java 类。

If you want to reference another jar containing the "API", you can add it to the project's build path.

如果要引用另一个包含“API”的 jar,可以将其添加到项目的构建路径中。

Say the jar is in the "lib" folder of your project, open the project properties (alt+enter), the Select Java Build Path, then the Librariestab, select Add JARs..., then browse to the lib folder and select the jar you want to add and select OK.

假设 jar 位于项目的“lib”文件夹中,打开项目属性 ( alt+enter),选择Java 构建路径,然后是选项卡,选择添加 JARs...,然后浏览到 lib 文件夹并选择您的 jar要添加并选择确定。

To attach sources and javadoc to the jar, you can expand the selector in the Libraries tab, click on Source attachmentand Edit...and browse to the location of the sources jar/zip, repeat for the Javadoc. The screenshot below shows you the Source attachment option for rt.jar

要将源和 javadoc 附加到 jar,您可以展开库选项卡中的选择器,单击源附件编辑...并浏览到源 jar/zip 的位置,对 Javadoc 重复。下面的屏幕截图显示了 rt.jar 的源附件选项

Libraries screenshot
(source: vogella.de)

图书馆截图
(来源:vogella.de

and ok back to the workbench.

然后回到工作台。

You should now see that the jar is included on the project's path (the jar has a little overlaid icon on it).

您现在应该看到该 jar 包含在项目的路径中(该 jar 上有一个小的覆盖图标)。

If this is not what you're after, can you rephrase the question?

如果这不是你所追求的,你能改写这个问题吗?

回答by Jesper

Do you mean: how to use a third-party Java library in your Java project in Eclipse?

您的意思是:如何在 Eclipse 中的 Java 项目中使用第三方 Java 库?

Right-click your project in the Package Explorer and choose Properties. Go to "Java Build Path". Click "Add JARs" or "Add External JARs" to add the JAR file(s) of the library to your project.

在 Package Explorer 中右键单击您的项目并选择 Properties。转到“Java 构建路径”。单击“添加 JAR”或“添加外部 JAR”将库的 JAR 文件添加到您的项目中。

"Add JARs" is for adding JAR files that are in your project directory. "Add External JARs" is for adding JAR files that are not in your project.

“添加 JAR”用于添加项目目录中的 JAR 文件。“添加外部 JAR”用于添加不在您的项目中的 JAR 文件。

Note that the Eclipse help (Help / Help Contents) contains a lot of information, including information on how to work with Java projects in Eclipse and how to add libraries to your Java project.

请注意,Eclipse 帮助(Help / Help Contents)包含大量信息,包括有关如何在 Eclipse 中使用 Java 项目以及如何向 Java 项目添加库的信息。

回答by Narayan

Yes, how to use JavaDoc file in eclipse.

是的,如何在 Eclipse 中使用 JavaDoc 文件。

You can download the Javadoc jar file from the respective project and include it in your build path

您可以从相应的项目下载 Javadoc jar 文件并将其包含在您的构建路径中

Eclipse==> project-->properties-->Java Build Path-->click on the jar file--> edit JavaDoc

Eclipse==>项目-->属性-->Java Build Path-->点击jar文件-->编辑JavaDoc

Point it to the API URL location/Downloaded Jar file,

将其指向 API URL 位置/下载的 Jar 文件,

Typically, shift + F2 opens the API when the class is focussed upon

通常,当关注类时,shift + F2 打开 API

回答by Robert Munteanu

Here are some nice Eclipse video tutorials. The version of Eclipse is dated ( 3.1 ), but the concepts are still there.

这里有一些不错的Eclipse 视频教程。Eclipse 的版本已经过时 ( 3.1 ),但概念仍然存在。

回答by abc

what you need to do is to hover mouse over some in-built method or class that are using in your program. Hold ctrl on your keyboard and click. Then eclipse asks you to attach source. click on 'attach source', browse for src.zip file after choosing 'EXTRENAL' file. or instead give path for extracted src folder under same ie external file attachment. Next time you hover over an in-built class or method it shows a small description. To view entire javadoc for same, keep holding ctrl and click on it. It worked for me.

您需要做的是将鼠标悬停在程序中使用的某些内置方法或类上。按住键盘上的 ctrl 并单击。然后 eclipse 会要求您附加源代码。单击“附加源”,选择“外部”文件后浏览 src.zip 文件。或者改为在相同的外部文件附件下为提取的 src 文件夹提供路径。下次您将鼠标悬停在内置类或方法上时,它会显示一个小说明。要查看相同的整个 javadoc,请按住 ctrl 并单击它。它对我有用。