Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Jar file manifest
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: runme.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.



Report this thread to moderator Post Follow-up to this message
Old Post
efinery
07-31-04 01:57 AM


Re: Jar file manifest
Apologies, I made a typo. The mainfest for mainapp.jar is as follows :

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



Report this thread to moderator Post Follow-up to this message
Old Post
efinery
07-31-04 01:57 AM


Re: Jar file manifest
efinery wrote:
> 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: runme.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?

Sure.  You're reading the documentation wrong.  What you are attempting
is not supposed to work.  The Class-Path manifest attribute lists other
jar files that will be in the same directory as the one you're running,
NOT other jar files that are recursively packaged inside the one you're
running.

There is no default classloader that's capable of loading classes from a
nested jar file.  You could write your own, though, by using getResource
to get a URL for the nested JAR file, and then URLClassLoader to load
classes from it.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Smith
07-31-04 01:56 PM


Re: Jar file manifest
efinery <hugh@efinery.com> wrote:
> Is it possible to run a jar file that is contained within another jar file?[/color
]

AFAIK, no. But you can use the Class-Path: header to reference jar files
in the same directory.

So if you place test.jar and mainapp.jar in the same directory, and the
manifest of mainapp.jar contains the line below, it'll work:

Class-Path: test.jar


--
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2

Report this thread to moderator Post Follow-up to this message
Old Post
Oscar kind
07-31-04 01:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:26 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.