You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by not4google <ka...@jpmorgan.com> on 2009/09/30 13:22:01 UTC

Adding multiple external JARS using Ant

Hi all

I have the following target:

	<target name="CreateExecutableJarFile">
		<jar destfile="XXX.jar">
			<zipfileset dir="build/classes" prefix="" />
			<zipfileset dir="lib" />
			<manifest>
				<attribute name="Main-Class" value="com.x.y.z.Hello" />
			</manifest>
		</jar>
	</target>

When I run the JAR from the command line I get ClassNotFoundExceptions and
this is because some external JARS are not accessible. How can I add
numerous external JARS e.g. Spring.jar so this all works?
-- 
View this message in context: http://www.nabble.com/Adding-multiple-external-JARS-using-Ant-tp25679172p25679172.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Adding multiple external JARS using Ant

Posted by not4google <ka...@jpmorgan.com>.
Thanks for the info I decided to specify each of the JARS as turned out only
needed 3 in any case. Now when I run the app I get an error as a XML file
cannot be found. 

I did the following in the ant target:

<zipfileset file="src/java/x-jdbc.xml" prefix="" />

and this file exists in my JAR but when running the JAR the file cannot be
found? 



Rebhan, Gilbert wrote:
> 
>  
> 
> -----Original Message-----
> From: not4google [mailto:kapil.x.johri@jpmorgan.com] 
> Sent: Wednesday, September 30, 2009 1:41 PM
> To: user@ant.apache.org
> Subject: RE: Adding multiple external JARS using Ant
> 
> /*
> Thanks for the info but what I needed was to add all JARS within a
> directory
> rather than specifying each one if thats possible?
> */
> 
> wildcards are not allowed in manifest context, see =
> 
> http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
> "...
> The CLASSPATH environment variable is not treated any differently from the
> -classpath
> (or -cp) command-line option. That is, wildcards are honored in all these
> cases.
> However, class path wildcards are not honored in the Class-Path
> jar-manifest header.
> ..."
> 
> 
> maybe, putting your jars into root of directory-name (recursion will not
> work probably)
> and =
> 
> <manifest>
>   ...
>   <attribute name="Class-Path" value="directory-name" />
> ...
> </manifest>
> 
> will work !?  never used it ..
> 
> 
> Regards, Gilbert
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-multiple-external-JARS-using-Ant-tp25679172p25679912.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Adding multiple external JARS using Ant

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
 

-----Original Message-----
From: not4google [mailto:kapil.x.johri@jpmorgan.com] 
Sent: Wednesday, September 30, 2009 1:41 PM
To: user@ant.apache.org
Subject: RE: Adding multiple external JARS using Ant

/*
Thanks for the info but what I needed was to add all JARS within a directory
rather than specifying each one if thats possible?
*/

wildcards are not allowed in manifest context, see =

http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
"...
The CLASSPATH environment variable is not treated any differently from the -classpath
(or -cp) command-line option. That is, wildcards are honored in all these cases.
However, class path wildcards are not honored in the Class-Path jar-manifest header.
..."


maybe, putting your jars into root of directory-name (recursion will not work probably)
and =

<manifest>
  ...
  <attribute name="Class-Path" value="directory-name" />
...
</manifest>

will work !?  never used it ..


Regards, Gilbert


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


RE: Adding multiple external JARS using Ant

Posted by not4google <ka...@jpmorgan.com>.
Thanks for the info but what I needed was to add all JARS within a directory
rather than specifying each one if thats possible?

Rebhan, Gilbert wrote:
> 
>  
> 
> -----Original Message-----
> From: not4google [mailto:kapil.x.johri@jpmorgan.com] 
> Sent: Wednesday, September 30, 2009 1:22 PM
> To: user@ant.apache.org
> Subject: Adding multiple external JARS using Ant
> 
> /*
> 
> Hi all
> 
> I have the following target:
> 
> 	<target name="CreateExecutableJarFile">
> 		<jar destfile="XXX.jar">
> 			<zipfileset dir="build/classes" prefix="" />
> 			<zipfileset dir="lib" />
> 			<manifest>
> 				<attribute name="Main-Class" value="com.x.y.z.Hello" />
> 			</manifest>
> 		</jar>
> 	</target>
> 
> When I run the JAR from the command line I get ClassNotFoundExceptions and
> this is because some external JARS are not accessible. How can I add
> numerous external JARS e.g. Spring.jar so this all works?
> 
> */
> 
> <manifest>
>   ...
>   <attribute name="Class-Path" value="jar1-name jar2-name
> directory-name/jar3-name" />
> ...
> </manifest>
> 
> see =
> http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
> 
> 
> Regards, Gilbert
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-multiple-external-JARS-using-Ant-tp25679172p25679400.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


RE: Adding multiple external JARS using Ant

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
 

-----Original Message-----
From: not4google [mailto:kapil.x.johri@jpmorgan.com] 
Sent: Wednesday, September 30, 2009 1:22 PM
To: user@ant.apache.org
Subject: Adding multiple external JARS using Ant

/*

Hi all

I have the following target:

	<target name="CreateExecutableJarFile">
		<jar destfile="XXX.jar">
			<zipfileset dir="build/classes" prefix="" />
			<zipfileset dir="lib" />
			<manifest>
				<attribute name="Main-Class" value="com.x.y.z.Hello" />
			</manifest>
		</jar>
	</target>

When I run the JAR from the command line I get ClassNotFoundExceptions and
this is because some external JARS are not accessible. How can I add
numerous external JARS e.g. Spring.jar so this all works?

*/

<manifest>
  ...
  <attribute name="Class-Path" value="jar1-name jar2-name directory-name/jar3-name" />
...
</manifest>

see =
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html


Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org