Reputation: 125
My project structure is as below
TestProject
|
|---- src
| |
| |---- package
| |
| |---- main.java
|
|---- externaLibs
|
|---- lib.jar
The manifest.txt is as below:
Manifest-Version: 1.0
Created-By: 1.7.0_06 (Oracle Corporation)
Main-Class: package.Main
Class-Path: ../externaLibs/lib.jar ./externaLibs/lib.jar /externaLibs/lib.jar externaLibs/lib.jar lib.jar (However I've tried these class paths to the lib.jar, none of them works)
Exporting my project with Eclipse, then, when executing the command: java -jar main.jar, the exception about being unable to find the external lib.jar always occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: org/example/SomeClassInLib
The output jar structure is as below:
testproject.jar
|
|---- externaLibs
| |
| |---- lib.jar
|
|---- pasckage
| |
| |---- main.java / main.class / and so on...
|
|---- META-INF
|
|---- MANIFEST.MF
What is the problem with the manifest.txt ?
Thanks for help.
Upvotes: 0
Views: 953
Reputation: 128
In eclipse when you export, there is an option to export as Runnable Jar File. You can use the library handling radio buttons in the wizard to choose how the dependencies are handled. With the first two options, the dependencies get added into your jar. The third option creats an output folder and places the dependency jars in an accessible location for your jar.
Upvotes: 1