Java:在 Eclipse 中导出到 .jar 文件

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

Java: export to an .jar file in eclipse

javaeclipseexecutableextractexe

提问by Adis

I'm trying to export a program in Eclipse to a jar file.

我正在尝试将 Eclipse 中的程序导出到 jar 文件。

In my project I have added some pictures and PDF:s. When I'm exporting to jar file, it seems that only the mainhas been compiled and exported.

在我的项目中,我添加了一些图片和 PDF:s。当我导出到 jar 文件时,似乎只main编译并导出了 jar 文件。

My will is to export everything to a jar file if it's possible, because then I want to convert it to an extraditable file, like .exe-file.

如果可能的话,我的意愿是将所有内容导出到 jar 文件,因为那样我想将其转换为可引渡文件,例如 .exe 文件。

But how?

但是如何?

采纳答案by Yuval Adam

No need for external plugins. In the Export JARdialog, make sure you select allthe necessary resources you want to export. By default, there should be no problem exporting other resource files as well (pictures, configuration files, etc...), see screenshot below. JAR Export Dialog

无需外部插件。在“导出 JAR”对话框中,确保选择要导出的所有必要资源。默认情况下,导出其他资源文件(图片、配置文件等)应该没有问题,请参见下面的截图。 JAR 导出对话框

回答by VonC

FatJarcan help you in this case.

在这种情况下,FatJar可以帮助您。

In addition to the"Export as Jar" function which is included to Eclipse the Plug-In bundles all dependent JARs together into one executable jar.
The Plug-In adds the Entry "Build Fat Jar" to the Context-Menu of Java-projects

除了包含在 Eclipse 中的“Export as Jar”功能之外,插件还将所有依赖的 JAR 捆绑到一个可执行的 jar 中。
该插件将条目“Build Fat Jar”添加到 Java 项目的上下文菜单中

This is useful if your final exported jar includes other external jars.

如果您最终导出的 jar 包含其他外部 jar,这将很有用。

If you have Ganymede, the Export Jar dialog is enough to export your resources from your project.

如果您有 Ganymede,Export Jar 对话框足以从您的项目中导出您的资源。

After Ganymede, you have:

在木卫三之后,你有:

Export Jar

出口罐

回答by Yuval Adam

Go to file->export->JAR file, there you may select "Export generated class files and sources" and make sure that your project is selected, and all folder under there are also! Good luck!

转到文件->导出-> JAR文件,在那里您可以选择“导出生成的类文件和源”并确保您的项目被选中,并且那里的所有文件夹也是!祝你好运!

回答by Peter Smith

One more option is WinRun4J. There is an Eclipse Plugin for WinRun4Jthat allows you to export your application as a single executable with necessary jars/classes embedded.

一种选择是WinRun4J。有一个用于 WinRun4JEclipse 插件,它允许您将应用程序导出为单个可执行文件,其中嵌入了必要的 jars/类。

(full disclosure: I work on this project)

(完全披露:我从事这个项目)