Java执行jar,它依赖于命令行中的其他jar [英] Java execute jar which depends on other jar from command line

查看:193
本文介绍了Java执行jar,它依赖于命令行中的其他jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用外部jar的应用程序。我使用了eclipse,效果很好。我从eclipse导出为jar,创建了清单文件,该文件具有Class-Path:./cab.v1.jar
我将两个jar都放在了同一目录中。
我在命令行中运行:
java -jar myApp.jar

I have an application that uses an external jar. I used eclipse and it works fine. 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. I run in command line: java -jar myApp.jar

并获取 java.lang.NoClassDefFoundError cab.v1.jar(另一个jar)中的类
也尝试了java -cp。 -jar myApp.jar,但未成功。
我在做什么错了?

and get java.lang.NoClassDefFoundError for the classes in the cab.v1.jar (the other jar) Have also tried java -cp . -jar myApp.jar but no success. 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

请注意,使用 -jar -cp 选项会被忽略code>。

Note that the -cp option is ignored when using -jar.

这篇关于Java执行jar,它依赖于命令行中的其他jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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