Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Jar manifest problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Jar manifest problem" Watch "Jar manifest problem" New topic
Author

Jar manifest problem

Hugh O'Donnell
Greenhorn

Joined: Jul 30, 2004
Posts: 13
Is it possible to run a jar file that is contained within another jar file? I have tried and can't seem to get it to work.
I have the following manifest in test.jar :

Manifest-Version: 1.0
Main-Class: com.efinery.RunTest

This runs fine using "java -jar test.jar" from the command line. However, when I place it inside a jar called mainapp.jar and have it's manifest reference test.jar in the Classpath as follows :

Manifest-Version: 1.0
Main-Class: com.efinery.RunTest
Classpath: test.jar

When I try to run "java -jar mainapp.jar" I get a java.lang.NoClassDefFoundError. Can anybody tell me what I am doing wrong? Any help would be much appreciated.


Hugh O'Donnell<br /> <br />SCJP 1.4, SCJD, SCBCD 1.3, SCWCD 1.4
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Is diskussed nearby: here


http://home.arcor.de/hirnstrom/bewerbung
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Are you running from the directory that the jar is stored in?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Hugh O'Donnell
Greenhorn

Joined: Jul 30, 2004
Posts: 13
Thanks for the help guys, but unfortunately still no luck.
I did try as you suggested Stefan, using the following manifest in mainapp.jar :

Main-Class: com.efinery.RunTest
Class-Path: test.jar .
<a blank line here>

Marilyn, as you asked, you I am running from the directory that contains the jar. Also in the same directory is the original test.jar that is also inside mainapp.jar. I should say that mainapp.jar contains no java code, only some documentation and source code. I simply want the mainfest in mainapp.jar to run the manifest in the nested test.jar.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
It sounds like you are trying to display the manifest. I think that will never happen. What if you put the text as a constant String inside a class in the jar and do a System.out.println() on it, jar it, and then run it.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Hugh O'Donnell:
Thanks for the help guys, but unfortunately still no luck.
I did try as you suggested Stefan, using the following manifest in mainapp.jar : ...



I had to correct myself there (and did it) on July 30, 2004 05:40 PM.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar manifest problem
 
Similar Threads
Why can't run?
jar files - classNotFoundException
self executable jar
J2EE & client applications. HELP PLEASE
why is this happening REALLY URGENT