构建包含所有依赖项的 JAR [英] Building JAR that includes all its dependencies

查看:41
本文介绍了构建包含所有依赖项的 JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题,但恐怕我对 Java 了解不多,而且在任何地方都找不到答案.

This is probably a really fundamental question, but I'm afraid I don't know much about Java and I couldn't find the answer anywhere.

我正在尝试构建一个依赖于 TFS SDK 的 Ant 库.我按照指南来设置项目,但是当我将其导出为 JAR 时并尝试使用 ANT 运行任务我收到以下错误:

I'm attempting to build an Ant library which depends on the TFS SDK. I followed the guide to setting up a project, but when I export it as a JAR and try to run a task using ANT I get the following error:

java.lang.NoClassDefFoundError: /com/microsoft/tfs/core/util/TFSUser

我意识到我可以将 TFS SDK JAR 放在我的 ANT lib 文件夹中,但如果可能的话,我希望我的 JAR 包含它,并且该库无需这样做就可以工作.

I realise I could put the TFS SDK JAR in my ANT lib folder, but if possible I'd like my JAR to include it and the library just work without having to do so.

这个答案 似乎说这是可能的包括使用 Eclipse 运行所需的所有资源(我使用的是 3.7.2),但它没有详细说明如何实际执行.Eclipse 中有什么选项可以这样做?

This answer seems to say it's possible to include all the resources needed to run using Eclipse (I'm using 3.7.2) but it doesn't detail how to actually do it. What is the option in Eclipse to do so?

推荐答案

在导出时选择将所需的库提取到生成的 JAR 中".

Select "Extract required libraries into generated JAR" as you do the export.

在导出时选择将所需的库提取到生成的 JAR 中".

Select "Extract required libraries into generated JAR" as you do the export.

这篇关于构建包含所有依赖项的 JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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