Java API 文档

发布于 2024-12-25 22:50:59 字数 243 浏览 3 评论 0原文

如何将 Java 文档添加到 .JAR 文件中,以便人们在使用我的 JAR 文件时键入“.” Eclipse 将显示可用 API(智能感知)的文档。

更多信息

我创建了 java 文档,但是当我导出 jar 文件时,在其他项目中使用时它不包含智能感知。这就是我遇到的麻烦。

更新 仅当导出源时才会显示智能感知。不过我想隐藏源代码。我该如何解决这个问题?

How can I add Java documentation to a .JAR file so that when people are using my JAR file and type '.' Eclipse will display the documentation for the available API's (intellisense).

MORE INFO

I have java doc created but when I export the jar file it does not contain intellisense when used in other projects. This is what I am having trouble with.

UPDATE
The intellisense only shows up if the export the source. However I want to hide the source code. How can I get around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江湖彼岸 2025-01-01 22:50:59

如果您不想在 .jar 中包含整个源代码,您可以只压缩/jar javadoc(但是您生成它们......我使用 Eclipse 中的 Project->Generate Javadoc 菜单选项来完成此操作)。然后,最终用户可以将它们“附加”到项目构建路径设置中引用的库。

项目库的 javadoc 位置属性可以是 URL、本地目录或本地存档文件。

注意到您的编辑后,我可能想提一下 Ant 有一个 javadoc 任务可以在构建期间生成您的javadoc。

If you don't want to include the entire source code with your .jar, you can zip/jar up just the javadocs (however you generate them.. I do it using the Project->Generate Javadoc menu option in Eclipse). An end user can then "attach" them to the referenced library in the project build path settings.

The javadoc location attribute of a project library can be a URL, a local directory or a local archive file.

After noticing your edits, I might want to mention that Ant has a javadoc task that can generate your javadocs during a build.

夏花。依旧 2025-01-01 22:50:59

Maven 有一种非常优雅的方式来处理这个问题。

第 1 步:生成 javadocs 的 Maven 方式: http://maven.apache.org/plugins/maven-javadoc-plugin/

步骤 2:确保 Eclipse 始终附加这些文档,使用 maven-eclipse-plugin< /a>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
      <downloadJavadocs>true</downloadJavadocs>
    </configuration>
</plugin>

完成这两个步骤后,API jar 的使用者将始终拥有最新的 javadoc,无需进一步干预

Maven has a very elegant way of handling this.

Step 1: The Maven way to generate javadocs: http://maven.apache.org/plugins/maven-javadoc-plugin/

Step 2: To ensure Eclipse always attaches these docs, use the maven-eclipse-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
      <downloadJavadocs>true</downloadJavadocs>
    </configuration>
</plugin>

Once these two steps are done, the consumers of your API jars will always have your latest javadocs with no further intervention

谁对谁错谁最难过 2025-01-01 22:50:59

在 Eclipse 中,导出带有源的项目。

执行文件 ->导出...-> Java-> JAR 文件 -> Next

然后选择复选框 Export java source files and resources。

然后继续直到创建 JAR。

编辑:问题编辑后,此答案不再有效,但仍然有用。

In Eclipse, export the project with sources.

Do File -> Export... -> Java -> JAR File -> Next

Then select the checkbox Export java source files and resources.

Then go on until the JAR is created.

Edit: after the edits in the question, this answer is no longer valid, but it is still useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文