Search code examples
javajarmanifestexecutable-jar

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:

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:

jar cmf manifest.mf App.jar src/*.class

But when I try to execute the App.jar file with

java -jar App.jar

I get the error message:

Caused by: java.lang.NoClassDefFoundError: App (wrong name: src/App)

Here is my 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!


Solution

  • the compiler is trying to tell you that it has a package srcApp;. You need to run it from the package root on.