[英]Java execute jar which depends on other jar from command line
I have an application that uses an external jar. 我有一个使用外部jar的应用程序。 I used eclipse and it works fine.
我使用了eclipse,效果很好。 I export as jar from eclipse, having created a Manifest file that has as Class-Path: ./cab.v1.jar I place both jars in the same directory.
我从eclipse导出为jar,创建了一个清单文件,该文件具有Class-Path:./cab.v1.jar,我将两个jar都放在了同一目录中。 I run in command line: java -jar myApp.jar
我在命令行中运行:java -jar myApp.jar
and get java.lang.NoClassDefFoundError for the classes in the cab.v1.jar (the other jar) Have also tried java -cp . 并为cab.v1.jar(另一个jar)中的类获取java.lang.NoClassDefFoundError也尝试了java -cp。 -jar myApp.jar but no success.
-jar myApp.jar,但未成功。 What am I doing wrong?
我究竟做错了什么?
Using the documentation for the Manifest it does not use a ./
for relative directories. 使用清单文件 ,相对目录不使用
./
。 Try it just with: 尝试使用:
Class-Path: cab.v1.jar
Note that the -cp
option is ignored when using -jar
. 请注意,使用
-jar
时-cp
选项将被忽略。
If you use the -jar
option the classpath is ignored. 如果使用
-jar
选项,则忽略类路径。 You could start the application by 您可以通过以下方式启动应用程序
java -cp jar1.jar:jar2.jar mainclass
The class path separator ':' is ';' 类路径分隔符':'为';' on windows.
在窗户上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.