ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Applying a classpath to a executable jar file
Date Tue, 04 Jun 2002 16:04:06 GMT
At least for java.exe, and probably for <java> as well, running with
java.exe -jar myjar.jar ignores any classpath setting, so you must indeed
set the Class-Path: attribute in the manifest in addition to setting the
Main-Class: attribute. Create a Manifest file that lists all the jars you
depend on, one per line, with path relative to the jar you're creating, with
the first character of each line a space, and the lines no longer than 72
characters. Once processed by jar.exe or <jar>, all these lines will be
concatenated with one space between them, and from column 1 to 72, cutting
words in the middle.

All the paths used must be relative to the location of the jar that lists
them in its manifest. Using <pathconvert> and <replace> (or <copy> with
filters), I generate the in-manifest classpath dynamically, and I believe I
already posted it to ant-user, so look for it in the searchable archives if
you want, or come up with your own version (it's not too difficult).

Hope this helps. <DD/>

--- Original Manifest ---
Main-Class: <snip/>
Class-Path: 
 ./dependency1.jar 
 ../dependency2/lib/dependency2.jar 
 ../dependency3/jar/dependency3.jar
Specification-Title: <snip/>
Specification-Version: <snip/>
Specification-Vendor: <snip/>
Implementation-Title: <snip/>
Implementation-Version: <snip/>
Implementation-Vendor: <snip/>
Implementation-Vendor-Id: <snip/>

--- In-JAR Manifest ---
Manifest-Version: <snip/>
Implementation-Version: <snip/>
Specification-Title: <snip/>
Specification-Version: <snip/>
Implementation-Title: <snip/>
Main-Class: <snip/>
Created-By: Ant 1.4.1
Class-Path: ./dependency1.jar ../dependency2/lib/dependency2.jar ../de
 pendency2/jar/dependency2.jar
Implementation-Vendor-Id: <snip/>
Implementation-Vendor: <snip/>
Specification-Vendor: <snip/>

-----Original Message-----
From: Ionel Gardais [mailto:Ionel.Gardais@geomath.fr] 
Sent: Tuesday, June 04, 2002 3:26 AM
To: ant-user@jakarta.apache.org
Subject: Applying a classpath to a executable jar file

Hi,

i'm trying to run a Java program directly from a .jar file.

The MANIFEST.MF contains the needed tag to run the main class but it
does'nt find the needed external packages.

I've tried to add a <classpath></classpath> tag inside the java tag but
it doesn't work.
I've also tried to include a Class-Path: tag in the MANIFEST.MF as
describe by Sun but java complains that the line is too long.
Finally, I'ce tried to include the needed external jars in my own jar.

It works but the file is now about 6 Mb ! Hard to download with a 56kbps
modem.

Is there a way to bypass this ?

Thanks for your help,
ionel


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message