分发 Java 文件的最佳方式
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以考虑使用 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.
有许多工具可以将一堆 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.
您可以使用 IzPack
You can use IzPack