[英]how to run a class in the jar file which is in the classpath of another jar file
I have a jar file called "a.jar" which has another jar file called "b.jar". 我有一个名为“ a.jar”的jar文件,其中还有一个名为“ b.jar”的jar文件。
a.jar
|
|-- META-INF
| |
| |-- MANIFEST.MF
|
|-- b.jar
|
|- com/test/MainInB.class
"b.jar" has com/test/MainInB.class file. “ b.jar”具有com / test / MainInB.class文件。 (MainInB class just print out "hello world!")
(MainInB类仅打印出“ hello world!”)
"a.jar" has the MANIFES.MF like this: “ a.jar”具有MANIFES.MF如下所示:
Manifest-version: 1.0
Main-Class: com.test.MainInB
Class-Path: b.jar
(The manifest file does end with empty new line) (清单文件确实以空的新行结尾)
And I would like to run the a.jar like this so it prints out "hello world!" 而且我想像这样运行a.jar,以便打印出“ hello world!”
java -jar a.jar
java -jar a.jar
But I got NoClassDefFoundError! 但是我收到了NoClassDefFoundError!
Please Help! 请帮忙! Is this not allowed?
这是不允许的吗? Or am I missing something?
还是我错过了什么?
R Joe 乔
Actually my example works! 其实我的例子有效!
I'm just having problem with my project in which I use maven-assembly-plugin to create jar and MANIFEST.MF. 我在使用maven-assembly-plugin创建jar和MANIFEST.MF的项目中遇到问题。
Something must be off in the configuration or the plugin. 配置或插件中的某些内容必须关闭。
Thanks anyway guys! 谢谢大家!
Joe 乔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.