分发 Java 文件的最佳方式

发布于 2024-10-08 12:31:13 字数 314 浏览 0 评论 0原文

我有一个 Java 项目,它依赖于多个库,这些库作为 JAR 文件分发。当我构建项目时,我最终得到 myProject.jar 和一个 lib 文件夹,其中包含我使用的每个库的 JAR 文件。

为了分发我的项目,我想我可以压缩整个 dist 文件夹,但这不是很干净。

有没有办法为包含库的每个平台制作单独的可执行文件(对于 Mac,.app,对于 Windows,.exe,...)我可以分发的单个跨平台文件(最好是 JAR)?

谢谢!

I hava a Java project that relies on several libraries, which are distributed as JAR files. When I build my project, I end up with myProject.jar with a lib folder that contains a JAR file for each of the libraries I used.

To distribute my project, I suppose I could just zip up the entire dist folder, but that's not very clean.

Rather than making a separate executable for each platform (.app for Mac, .exe for Windows, ...) that contains the libraries, is there a way to make a single cross-platform file (preferably a JAR) that I can distribute?

Thanks!

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

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

发布评论

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

评论(3

不离久伴 2024-10-15 12:31:13

您可以考虑使用 Java Web Start

基本上,您创建一个配置文件并将其与您需要的任何 JAR 一起放在网站上。在该配置文件中,您可以指定需要下载的内容。下载完所有内容后,它会在用户的桌面上放置一个图标,以便他们启动您的程序。

您还可以将其配置为在必要时自动下载更新的 JAR。

You can consider using Java Web Start.

Basically, you create a configuration file and put it up on a web site, along with whatever JARs you need. In that configuration file, you can specify what it needs to download. After downloading everything, it puts an icon on the user's desktop for them to launch your program.

You can also configure it to automatically download updated JARs whenever necessary.

丿*梦醉红颜 2024-10-15 12:31:13

有许多工具可以将一堆 JAR 打包成一个。 Enrique 的建议是一个用于分发应用程序的更高级别的工具; JarJar 是一个更底层、更直接的工具,可以完全满足您的要求。

There are many tools that pack up a bunch of JARs into one. Enrique's suggestion is a higher-level tool for distributing applications; a lower-level more direct tool to do exactly what you ask is JarJar.

赤濁 2024-10-15 12:31:13

您可以使用 IzPack

You can use IzPack

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