aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Problem with jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Problem with jar" Watch "Problem with jar" New topic
Author

Problem with jar

Rupali Desai
Ranch Hand

Joined: May 29, 2001
Posts: 42
I have the following classes in my application and prepared a jar file using the following command
C:\ACG_JAVA>jar cvfm ACG1.jar Manifest.mf *.class
added manifest
adding: ACG.class(in = 21644) (out= 9466)(deflated 56%)
adding: Acg_xxa_reference.class(in = 5748) (out= 3287)(deflated 42%)
adding: ACGBadInputParameterException.class(in = 438) (out= 263)(deflated 39%)
adding: ACGConstant.class(in = 7434) (out= 2628)(deflated 64%)
adding: ACGException.class(in = 592) (out= 331)(deflated 44%)
adding: ACGFatalException.class(in = 414) (out= 250)(deflated 39%)
adding: ACGOutputType.class(in = 642) (out= 392)(deflated 38%)
adding: ACGParameter.class(in = 23927) (out= 8654)(deflated 63%)
adding: ACGReference.class(in = 5926) (out= 3125)(deflated 47%)
adding: ACGRuntimeMessage.class(in = 996) (out= 481)(deflated 51%)
adding: KeyValuePair.class(in = 363) (out= 255)(deflated 29%)
adding: TokenizeQueryString.class(in = 1932) (out= 1022)(deflated 47%)
The Manifest.mf reads like this
Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Class-Path: c:\tomcat\lib\common\servlet.jar
Main-Class: Acg_xxa_reference
When I try to execute the jar file as folllows
C:\ACG_JAVA>java -jar ACG1.jar
I get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: Acg_xxa_reference

What am I doing wrong
Thanks
Rupali Desai
Dan Richardson
Greenhorn

Joined: Aug 06, 2002
Posts: 23
I believe the problem is with your Class-Path attribute. From what I've read on the jar spec, this only accepts relative URL's. You could try the following:
Class-Path: ../tomcat/common/lib/servlet.jar
if you want to keep the same directory structure. Or for testing purposes, copy the servlet.jar over to your directory and simply refer to it as the following:
Class-Path: servlet.jar
and see what happens. Based on the tests I've run on my machine, either of these should work.
NOTE: I think you may have had your common and lib folders mixed up. I believe the default Tomcat installation uses ...common/lib instead of ..lib/common.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with jar