如何为具有多个包和库的项目生成可执行的.jar 文件?
我参与创建了一个项目,该项目包含大约 60 个包和 150 多个类以及一些外部库。我如何将这些东西打包到一个可执行的 jar 文件中,以便我可以将其作为应用程序运行。谁能提供详细步骤。
提前感谢回复者。
I am involved in creating a project which has around 60 packages and more than 150 classes and also some external libraries. How can i package these things in to a single executable jar file, so that i can run it as an application. can anyone please provide the detailed steps.
Thanks to the replier in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Eclipse 中选择“导出为可运行 JAR”。
如果您希望将所有内容都保存在一个文件中,请选择“将库提取到 JAR 中”。
In Eclipse choose 'Export as Runnable JAR'.
If you want it all in one file, choose 'extract libraries into JAR'.
我强烈建议你将其mavenize。从长远来看,使用 Apache Maven 会对您的项目描述有很大帮助。
I would strongly recommend you to mavenize it. Using Apache Maven will help you a lot in the long run with the project describe.
如果您使用的是 Netbeans,请右键单击您的项目,然后单击“清理并构建”。这将在项目的根目录中创建一个名为
dist
的文件夹。该文件夹包含jar
文件。If you are using Netbeans, right-click on your project, click on Clean and Build. This will create a folder named
dist
in your project's root directory. That folder contains thejar
file.您可以使用 maven 构建项目并使用 maven- 生成包含所有依赖项的 jar阴影插件
You can use maven to build your project and generate a jar with all of the dependencies with maven-shade-plugin