在Eclipse中生成包含外部库的jar [英] Generating a Jar in Eclipse including external library

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

问题描述

我有一个我在eclipse中编写的java应用程序。它工作正常。



它可以从导出它的目录中的命令行运行正常。在该目录中是另一个目录,其中包含两个应用程序需要的jar文件,并且清单文件具有指定它们的Class-path选项。



我想要一种方法使用eclipse生成必需的文件来打包这个应用程序以在另一台机器上运行。那可能吗?



如果我选择创建可执行的jar文件,它会创建这个巨大的文件;它解压缩并重新包装了两个库,我知道这是一个方法来实现它们的功能。如果他们作为自己的罐子留下来,我实际上会喜欢它,但是我不确定eclipse可以做到这一点。更令人讨厌的事实是,可执行的jar文件选项将我的eclipse项目中的大量文件放入该jar文件。我没有看到可以选择什么包含在那里,虽然我确实看到一个地方在项目属性中输入包含和排除规则,这些在这里应用吗?还有别的地方去选择什么和做什么没有包含在可执行jar中?



如果我选择创建jar(ins创建可执行jar),我看不到有哪些选项包括这两个jar文件在任何地方,也许没有地方可以包含他们可以使用的地方。



如果可能,我不想使用Ant,我不想使用Maven,我不想下载另一个工具,在我看来,Eclipse已经拥有所有这些信息,我怀疑它已经可以做到这一点,而不用去学习另一个漂亮的工具。 p>

解决方案

Eclipse有自己的Jar导出向导,用于生成包含所需库的可运行jar或将文件夹中所需的库放在jar旁边。



进入文件--->导出,然后选择Java - Runnable Jar





然后,您可以选择如何打包和如何处理库:





你也可以保存蚂蚁脚本供以后修改或使用...


I have a java application I've written in eclipse. It works fine there.

It works fine run from a command line in the directory where I export it to. In that directory is another directory containing two jar files that I need for the application, and the manifest file has a Class-path option specifying them.

I want a way to use eclipse to generate the necessary file(s) to package this application to run on another machine. Is that possible?

If I choose "create executable jar file", it creates this huge file; it does unpack and repack the two libraries, which I know is one way to get their functionality included. I would actually prefer it if they were left as their own jars somehow, but I am not certain eclipse can do that. More annoying is the fact that the executable jar file option puts lots of files from my eclipse project into that jar file. I don't see an option to choose what gets included there, though I do see a place to enter inclusion and exclusion "rules' in the project properties. Do those apply here? Is there somewhere else I go to select what does and does not get included in the "executable jar"?

If I choose "create jar" (ins of "create executable jar"), I don't see where there's an option to include these two jar files anywhere. Perhaps there is no place to include them where they could be used.

If possible, I do not want to use Ant, I do not want to use Maven, I do not want to download another tool. It seems to me that Eclipse already has all this information and I suspect it can already do this without having to go and learn yet another "nifty" tool.

解决方案

Eclipse has its own Jar export wizard for generate a runnable jar packed with required library or with the required library in a folder aside the jar.

Going in File ---> Export then choose Java - Runnable Jar

You can then choose how pack the jar and how handling libraries :

You can also save the ant script for later modification or use ...

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

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