如何使用一个依赖于另一个jar的jar [英] how to use one jar that depends on another jar

查看:161
本文介绍了如何使用一个依赖于另一个jar的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在我的应用程序MyClass中,我想在jar1中使用A类,而A类的某些部分依赖于jar2中的某个B类。如果我把jar1和jar2放在我的类路径上并运行MyClass,它仍然会抱怨找不到B类。

suppose in my application "MyClass", I want to use class A in jar1, and some part of class A depends on some class B in jar2. If I put both jar1 and jar2 on my classpath and run MyClass, it still complains that class B can not be found.

有人能告诉我如何解决这个问题吗?

Could anybody tell me how to fix this problem?

非常感谢。

推荐答案

java 命令与 -jar <时,<%CLASSPATH%环境变量忽略 / code>参数。使用 -classpath 参数或其简写 -cp 指定它。或者,您也可以在JAR文件的 MANIFEST.MF 文件的 class-path 条目中指定它。执行。

The %CLASSPATH% environment variable is ignored when you use java command with -jar argument. Specify it using -classpath argument or its shorthand -cp. Alternatively you can also specify it in the class-path entry of the MANIFEST.MF file of the JAR file which you execute.

这篇关于如何使用一个依赖于另一个jar的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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