NetBeans - 在一个jar中部署所有内容 [英] NetBeans - deploying all in one jar

查看:127
本文介绍了NetBeans - 在一个jar中部署所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

将外部库放到JAR上?

I有NetBeans 6.8,我写了一个有两个库(jar文件)的类。
构建它,我的project.jar和一个包含两个lib jar文件的lib文件夹的dist文件夹。

I have NetBeans 6.8 and I wrote one class which has two libraries (jar-files). Building it, I get a "dist" folder with my project.jar and a "lib" folder which contains the two lib jar files.

怎么可能我在一个jar文件中得到了所有这些?
(我不使用Maven / Ant或类似的东西。)

How could I get all this in one jar file? (I do not use Maven/Ant or something like this.)

推荐答案

基本问题是当前Java版本不支持开箱即用的jar中的jar。

The basic problem is that the current version of Java does not support jars inside jars out of the box.

建议的解决方案是使用jar中MANIFEST.MF文件中的Class-Path行指向所需的库(允许相对路径),然后将所有文件一起部署并使用java -jar your.jar调用它

The recommended solution is to use the Class-Path line in the MANIFEST.MF file inside your jar to point to required libraries (relative paths are allowed) and then deploy all files together and invoking it with "java -jar your.jar"

如果你真的想拥有一个jar-inside-jar解决方案,我们已经使用了一个罐子几年了,但是因为我们的目标JVM在上述解决方案中工作得更好,所以我们已经离开了它。

If you really want to have a "jar-inside-jar" solution, we have used one-jar for several years, but gone away from it since our target JVM worked better with the solution described above.

http://one-jar.sourceforge.net/

我在Eclipse中使用了fatjar插件。我没有将它构建到Netbeans中的任何经验,但是很容易构建成一个蚂蚁脚本,我相信它是NEtbeans所使用的。

I used it with the fatjar plugin in Eclipse. I do not have any experiences with building it into Netbeans, but it is simple to build into an ant script which I believe is what NEtbeans use anyway.

这篇关于NetBeans - 在一个jar中部署所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆