如何在Netbeans项目中包含外部jar [英] How can I include external jar on my Netbeans project

查看:100
本文介绍了如何在Netbeans项目中包含外部jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行clean and build时,正在创建的 .jar 文件仅在 lib 时运行文件夹位于 .jar 文件的同一文件夹中。

When I run "clean and build" the .jar file that is being created only runs if the lib folder is at the same folder of the .jar file.

因此,如果我将jar文件移动到桌面并在 lib 文件夹> dist 文件夹,jar文件会给我一个例外。

So if I move the jar file to the desktop and leave the lib folder in the dist folder, the jar file will give me an exception.

我该如何处理这个问题?

How can I deal with this problem?

推荐答案

如果将jar复制到源代码目录中,它们将在最后一个jar中。毫无疑问,我不确定这是否会100%有效。

If you copy your jars into the source code directory, they will be in your final jar. Nevetheless, I am not sure if this will work 100% of the time.

java-forum ,声明如下:


除了选择在一些情况下,最适合我的是
只需手动合并文件。 .jar基本上是一个带有
组织内容的.zip,你可以在几乎任何.zip的
存档程序中打开它们(我只使用gnome的标准存档,File Roller,
和它效果很好)。备份您的jar文件并在您选择的archiver
中打开它,并对库
目录中的每个库jar执行相同操作。将每个库中的工作文件夹(IE,除了
META-INF目录之外的所有内容)拖放到jar的根路径
(以及META-INF和应用程序的根包)旁边。现在将
META-INF / MANIFEST.MF文件从jar中拖到桌面或任何其他
文件夹中。打开它,擦除Class-Path和X-COMMENT行。不要
忘记在文件末尾留下空白换行符!保存新的
清单文件并将其拖回到jar的META-INF目录,
覆盖旧文件。测试罐子。

Except for a select few circumstances, what works best for me is to simply merge the files manually. A .jar is basically a .zip with organized contents, and you can open them in almost any .zip capable archive program (I just use gnome's standard archiver, File Roller, and it works great). Backup your jar file and open it in the archiver of your choice, and do the same for each library jar in the library directory. Drag and drop the working folders (IE, everything EXCEPT the META-INF Directory) from each library into your jar's root path (alongside your META-INF and your app's root package). Now drag the META-INF/MANIFEST.MF file from your jar to your Desktop or any other folder. Open it, and erase the Class-Path and X-COMMENT lines. Don't forget to leave a blank newline at the end of the file! Save the new manifest file and drag it back to your jar's META-INF directory, overwriting the old one. Test the jar.

这篇关于如何在Netbeans项目中包含外部jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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