You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Arpe, Kevin C" <Ke...@jpmorgan.com> on 2011/07/14 15:11:15 UTC

Including JARs and Class files

Hi,

I am trying to launch Ant v1.8.1 on Windows using Java 1.6.0_24.

I have some JARs and class files that I need to reference from my build.xml.

I tried a few combinations of CLASSPATH (please don't throw stones!) and -lib arguments.  None of can do what I want 100%.

In my dreams:
ant.bat -lib "MyProject\lib" -lib "MyProject\bin" -file build.xml <args>

Inside "MyProject\lib" there are many JARs that I want to include.  I don't want to specify by name because sometimes the names change (when JAR versions change).
Inside "MyProject\bin" is a tree of class files.  Example: "MyProject\bin\net\sf\blah\blah\blah\ThisOrThat.class"

I also tried using CLASSPATH:
set CLASSPATH=MyProject\lib*;MyProject\bin

This also does not work.  For some reason, the * is not exploded to a list of JARs by the JVM.  I assume it would work like the -classpath arg for the JVM.

At the moment, I am using the worst case scenario: CLASSPATH with specific JAR files names.

Surely, I can do better, but I don't know how.  =(

Can you please advise?  I am sure I am very close(!)... but just one or two characters away.

Thanks in advance,
Arpe
Hongkong



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Re: Including JARs and Class files

Posted by Vimil Saju <vi...@yahoo.com>.
Try  this

set CLASSPATH=MyProject\bin

ant.bat -lib "MyProject\lib"  -file build.xml <args>


If I remember correctly, the -lib parameter is used to only add jar files to the classpath. you can't use it to add class files to the classpath

java 6 supports using wildcards in the class path.

so you could also try
set CLASSPATH=MyProject\bin;MyProject\lib\*

ant.bat  -file build.xml <args>





________________________________
From: "Arpe, Kevin C" <Ke...@jpmorgan.com>
To: "user@ant.apache.org" <us...@ant.apache.org>
Sent: Thursday, July 14, 2011 6:11 AM
Subject: Including JARs and Class files

Hi,

I am trying to launch Ant v1.8.1 on Windows using Java 1.6.0_24.

I have some JARs and class files that I need to reference from my build.xml.

I tried a few combinations of CLASSPATH (please don't throw stones!) and -lib arguments.  None of can do what I want 100%.

In my dreams:
ant.bat -lib "MyProject\lib" -lib "MyProject\bin" -file build.xml <args>

Inside "MyProject\lib" there are many JARs that I want to include.  I don't want to specify by name because sometimes the names change (when JAR versions change).
Inside "MyProject\bin" is a tree of class files.  Example: "MyProject\bin\net\sf\blah\blah\blah\ThisOrThat.class"

I also tried using CLASSPATH:
set CLASSPATH=MyProject\lib*;MyProject\bin

This also does not work.  For some reason, the * is not exploded to a list of JARs by the JVM.  I assume it would work like the -classpath arg for the JVM.

At the moment, I am using the worst case scenario: CLASSPATH with specific JAR files names.

Surely, I can do better, but I don't know how.  =(

Can you please advise?  I am sure I am very close(!)... but just one or two characters away.

Thanks in advance,
Arpe
Hongkong



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.