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

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

问题描述

我有一个用 Eclipse 编写的 Java 应用程序.在那里工作正常.

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

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

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.

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

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?

如果我选择创建可执行jar文件",它会创建这个巨大的文件;它确实解包并重新打包这两个库,我知道这是包含其功能的一种方法.如果它们以某种方式被保留为自己的罐子,我实际上更喜欢它,但我不确定 eclipse 可以做到这一点.更令人讨厌的是,可执行 jar 文件选项将我的 eclipse 项目中的大量文件放入该 jar 文件中.我没有看到选择包含在那里的内容的选项,尽管我确实看到了在项目属性中输入包含和排除规则"的地方.这些是否适用于此处?还有其他地方我可以选择做什么和做什么未包含在可执行 jar"中?

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"?

如果我选择创建 jar"(创建可执行 jar"的插入),我看不到在哪里可以选择在任何地方包含这两个 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.

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

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 有自己的 Jar 导出向导,用于生成一个可运行的 jar,其中包含所需的库或在 jar 旁边的文件夹中的所需库.

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.

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

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

然后您可以选择如何打包 jar 以及如何处理库:

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

还可以保存ant脚本以备以后修改或使用...

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

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

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