Java:在 eclipse 中导出到 .jar 文件
我正在尝试将 Eclipse 中的程序导出到 jar 文件。
在我的项目中,我添加了一些图片和 PDF:s。 当我导出到 jar 文件时,似乎只有 main
已被编译和导出。
我的意愿是如果可能的话将所有内容导出到 jar 文件,因为这样我想将其转换为可引渡的文件,例如 .exe 文件。
但如何呢?
I'm trying to export a program in Eclipse to a jar file.
In my project I have added some pictures and PDF:s. When I'm exporting to jar file, it seems that only the main
has been compiled and exported.
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.
But how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
无需外部插件。 在导出 JAR 对话框中,确保选择所有要导出的必要资源。 默认情况下,导出其他资源文件(图片、配置文件等)应该没有问题,请参见下面的屏幕截图。
No need for external plugins. In the Export JAR dialog, make sure you select all the 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 文件,您可以选择“导出生成的类文件和源”并确保选择您的项目,并且下面的所有文件夹也都被选中! 祝你好运!
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!
FatJar 在这种情况下可以为您提供帮助。
除了 Eclipse 中包含的“导出为 Jar”功能之外,该插件还将所有相关 JAR 捆绑在一起到一个可执行 jar 中。
该插件将条目“Build Fat Jar”添加到 Java 项目的上下文菜单中。
如果您最终导出的 jar 包含其他外部 jar,这非常有用。
如果您有 Ganymede,“导出 Jar”对话框足以从项目中导出资源。
在 Ganymede 之后,您有:
FatJar can help you in this case.
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
This is useful if your final exported jar includes other external jars.
If you have Ganymede, the Export Jar dialog is enough to export your resources from your project.
After Ganymede, you have:
另一种选择是 WinRun4J。 有一个 WinRun4J 的 Eclipse 插件,它允许您将应用程序导出为单个可执行文件嵌入的罐子/类。
(全面披露:我从事这个项目)
One more option is WinRun4J. There is an Eclipse Plugin for WinRun4J that allows you to export your application as a single executable with necessary jars/classes embedded.
(full disclosure: I work on this project)