![](/img/trans.png)
[英]How to include a jar file in classpath and run another jar in linux
[英]how to run a class in the jar file which is in the classpath of another jar file
我有一个名为“ a.jar”的jar文件,其中还有一个名为“ b.jar”的jar文件。
a.jar
|
|-- META-INF
| |
| |-- MANIFEST.MF
|
|-- b.jar
|
|- com/test/MainInB.class
“ b.jar”具有com / test / MainInB.class文件。 (MainInB类仅打印出“ hello world!”)
“ a.jar”具有MANIFES.MF如下所示:
Manifest-version: 1.0
Main-Class: com.test.MainInB
Class-Path: b.jar
(清单文件确实以空的新行结尾)
而且我想像这样运行a.jar,以便打印出“ hello world!”
java -jar a.jar
但是我收到了NoClassDefFoundError!
请帮忙! 这是不允许的吗? 还是我错过了什么?
乔
其实我的例子有效!
我在使用maven-assembly-plugin创建jar和MANIFEST.MF的项目中遇到问题。
配置或插件中的某些内容必须关闭。
谢谢大家!
乔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.