Skip to main content

Problems creating complex jar file

1 reply [Last post]
aram535
Offline
Joined: 2008-03-28
Points: 0

I am trying to create a jar file from a class file about 60 external jar files that have dependencies on each other.

Here is the sample of manifest.txt file (which has an extra blank line at the bottom):

<br />
Manifest-Version: 1.0<br />
Created-By: 1.6.0_01 (Sun Microsystems Inc.)<br />
Main-Class: com.foo.test.client.UA<br />
Class-Path: lib/activation-1.1.jar<br />
 lib/annogen-0.1.0.jar<br />
 lib/axiom-api-1.2.5.jar<br />
 lib/axiom-dom-1.2.5.jar<br />
 lib/axiom-impl-1.2.5.jar<br />
 lib/axis2-adb-1.3.jar<br />
 lib/axis2-adb-codegen-1.3.jar<br />
 lib/axis2-ant-plugin-1.3.jar<br />
 lib/axis2-clustering-1.3.jar<br />
 lib/axis2-codegen-1.3.jar<br />
 lib/axis2-fastinfoset-1.3.jar<br />
 lib/axis2-java2wsdl-1.3.jar<br />
 lib/axis2-jaxbri-1.3.jar<br />
 ...<br />

# jar cvfm ../test.jar ../manifest.txt com/ lib/
# jar i test.jar
# java -jar test.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/Axis
Fault
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.AxisFault
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Weird thing is that if I "jar xf test.jar" so that the lib/ directory is exposed to java on the filesystem, it runs. It just doesn't know how to pull the lib directory out of the jar file?

Any suggestions would be greatly appreciated.

Aram

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rajisp
Offline
Joined: 2008-01-23
Points: 0

Hi.
I have this same problem.. But for me the jar file is executing only in the location where I created that jar file.. To execute that in other locations I should carry that external jar files folder to the desired location..That means jar file that I created not including the external jar files..

Did you solve your problem?I tried http://basittanveer.blogspot.com/2005/10/executable-jar-file-in-java.html
but its not working for me.