Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30787
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.tele2net.at!news.panservice.it!feed.xsnews.nl!border02.ams.xsnews.nl!feeder02.ams.xsnews.nl!frontend-F09-17.ams.news.kpn.nl |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Using jar inside a jar |
| Organization | Decebal Computing |
| References | <871tmn6qh9.fsf@Equus.decebal.nl> <cic570FsdhtU1@mid.individual.net> |
| X-Face | "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E |
| X-Homepage | http://www.decebal.nl/ |
| Date | Thu, 22 Jan 2015 13:05:11 +0100 |
| Message-ID | <87r3un58co.fsf@Equus.decebal.nl> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
| Cancel-Lock | sha1:4XVvGnVOe12o7fm65SmqrIbgk2k= |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Lines | 54 |
| NNTP-Posting-Host | 77.171.42.144 |
| X-Trace | 1421928802 news.kpn.nl 18714 77.171.42.144@kpn/77.171.42.144:41504 |
| Xref | csiph.com comp.lang.java.programmer:30787 |
Show key headers only | View raw
Op Thursday 22 Jan 2015 12:28 CET schreef Nigel Wade: > On 22/01/15 10:48, Cecil Westerhof wrote: >> To compile a program I use: >> javac -classpath ../ShowMemory/ShowMemory.jar \ >> -Xlint:all \ >> -Werror \ >> PanelTools.java >> >> To create a jar I use: >> jar -cvfm PanelTools.jar \ >> MANIFEST.MF \ >> images \ >> -C ../ShowMemory ShowMemory.jar \ >> *.class >> >> The MANIFEST.MF contains: >> Manifest-Version: 1.0 >> Main-Class: PanelTools >> Class-Path: ShowMemory.jar >> >> But when I execute the program with: >> java -jar PanelTools.jar & >> >> I get: Exception in thread "AWT-EventQueue-0" >> java.lang.NoClassDefFoundError: nl/decebal/utilities/ShowMemory >> >> What am I doing wrong? >> > > Java needs to know where to locate ShowMemory.jar. The only > information it has is the Class-Path: entry in MANIFEST.MF. This > entry only has a bare filename, so Java looks for it in the same > directory as the jar file it is executing. > > You have various options, none of which are perfect. 1) You can > embed an absolute path in the manifest. Ok if the dependency jar > will always be in the same place. 2) You can use a relative path in > the manifest. Better, but still only works if the jar and the > dependency will always have the same relative locations. 3) > Basically option 2, but during the build process copy all dependency > jar's to a fixed location relative to the main jar (e.g. lib/), and > use that relative path in the manifest. Best option, as it means you > can package the jar and its dependency tree if you need to relocate > it. It is not possible to use the jar that I put into the jar file? I would prefer to use only one jar file. But if that is not possible, I will go for option 3. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using jar inside a jar Cecil Westerhof <Cecil@decebal.nl> - 2015-01-22 11:48 +0100
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-22 11:28 +0000
Re: Using jar inside a jar Cecil Westerhof <Cecil@decebal.nl> - 2015-01-22 13:05 +0100
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-22 13:46 +0100
Re: Using jar inside a jar Jeff Higgins <jeff@invalid.invalid> - 2015-01-22 08:15 -0500
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-22 16:30 +0100
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-22 14:18 +0000
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-22 16:29 +0100
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-23 11:10 +0000
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-23 13:12 +0100
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-23 15:46 +0000
Re: Using jar inside a jar Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-23 11:18 -0500
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-23 22:42 +0100
Re: Using jar inside a jar Jerry Stuckle <jstucklex@attglobal.net> - 2015-01-23 17:02 -0500
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-24 14:14 +0100
Re: Using jar inside a jar Martin Gregorie <martin@address-in-sig.invalid> - 2015-01-24 15:33 +0000
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-26 09:28 +0000
Re: Using jar inside a jar Joerg Meier <joergmmeier@arcor.de> - 2015-01-26 21:14 +0100
Re: Using jar inside a jar Jerry Stuckle <jstucklex@attglobal.net> - 2015-01-26 15:23 -0500
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-28 14:19 +0000
Re: Using jar inside a jar Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-01-24 11:46 +0000
Re: Using jar inside a jar Wayne <nospam@all.invalid> - 2015-01-23 00:47 -0500
Re: Using jar inside a jar Silvio <silvio@internet.com> - 2015-01-23 12:28 +0100
Re: Using jar inside a jar Nigel Wade <nmw@ion.le.ac.uk> - 2015-01-22 14:18 +0000
csiph-web