[英]stuck into building jar with external jar dependency
I'm trying to build a executable jar only using the terminal with the following directory structure:我正在尝试仅使用具有以下目录结构的终端构建可执行 jar:
project-folder
|---lib
| |---commons-io-2.6.jar
|---src
| |---App.java
| |---App.class
| |---App$1.class
| |---App$2.class
|---manifest.mf
|---App.jar
How you can see I have already created the App.jar with the command:您如何看到我已经使用以下命令创建了 App.jar:
jar cmf manifest.mf App.jar src/*.class
But when I try to execute the App.jar file with但是当我尝试执行 App.jar 文件时
java -jar App.jar
I get the error message:我收到错误消息:
Caused by: java.lang.NoClassDefFoundError: App (wrong name: src/App)引起:java.lang.NoClassDefFoundError: App(错误名称:src/App)
Here is my manifest.mf:这是我的 manifest.mf:
Class-Path: lib/commons-io-2.6.jar
Main-Class: src/App
Can't see where the fault is and still searching for hours.. Thanks in advance!看不到故障在哪里,仍在寻找几个小时..提前致谢!
the compiler is trying to tell you that it has a package srcApp;.编译器试图告诉你它有一个 package srcApp;。 You need to run it from the package root on.您需要从 package 根目录上运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.