Reputation: 4136
I have a jar file called 'TJXLineFilterPlugin'. Value of MANIFEST.MF is
Manifest-Version: 1.0
Class-Path: c:\stdintjbt\java\lib\ojdbc14.jar c:\stdintjbt\java\lib\commons-lang-2.0.jar c:\stdintjbt\java\lib\jitterbit-plugin-sdk.jar c:\stdintjbt\java\lib\jitterbit-xml-utils.jar .
Created-By: 1.6.0_35 (Sun Microsystems Inc.)
Main-Class: org.jitterbit.plugins.tjx.TJXLineFilterPlugin
Tried running
java -jar E:\TJXLineFilterPlugin.jar
There is a folder strucrure inside the jar is
org/jitterbit/plugins/tjx/TJXLineFilterPlugin.class
But it throw the error like,
Exception in thread "main" java.lang.NoClassDefFoundError: org/jitterbit/plugins
/tjx/TJXLineFilterPlugin
Caused by: java.lang.ClassNotFoundException: org.jitterbit.plugins.tjx.TJXLineFi
lterPlugin
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.jitterbit.plugins.tjx.TJXLineFilterPlugin. Pr
ogram will exit.
I tried running with class path cp
also.
Upvotes: 0
Views: 234
Reputation: 2416
NoClassDefFoundError
usually means the class listed was found but could not be loaded because some of its dependencies could not be found.
I would point you to the Class-Path
entry in your MANIFEST file:
Class-Path: ... c:\stdintjbt\java\lib\ojdbc14.jar .
First, you should liste the dependent JARs with paths relative to the JAR in question (your JAR), and not use absolute paths like you did.
Second, I don't think .
should even be there because inner-JAR classpath is not the same as on-disk classpath where you are adding current working directory to the classpath with the .
.
UPDATE
A Java application is usually delivered / deployed in a following structure:
myapp/
applauncher (script or executable)
+ conf
+ logs
lib/
myapp.jar
a.jar
b.jar
...
For this example your Class-Path
entry should be:
Class-Path: ojdbc14.jar commons-lang-2.0.jar jitterbit-plugin-sdk.jar jitterbit-xml-utils.jar
Upvotes: 1
Reputation: 7804
Go to the specific directory containing the jar file and then execute the following command:
java -jar TJXLineFilterPlugin.jar
The path to specific class is always relative in your manifest. Executing the jar from different directory will not find the required classes.
Upvotes: 0