• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Set Ant Classpath for Compile

 
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If I have my classpath Windows XP environment variable defined, in this case .;C:\Sun\AppServer\lib\javaee.jar;C:\Java\lib\mysql.jar;, is it still necessary to define the classpath in the build.xml for Ant?

If yes can you help me convert the classpath shown above to what Ant requires?

Code and Ant output below.

Thanks,

Lou

File build.properties


File build.xml


Ant output
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it.

First in your buld.properties file
Lou.classpath=C:/Sun/AppServer/lib/javaee.jar;C:/Java/lib/mysql.jar

Second in your build.xml file
<path id="classpath.base">
<pathelement path="${Lou.classpath}"/>
</path>

Then add to your compile target in build.xml
<classpath refid="classpath.base"/>
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I have my classpath Windows XP environment variable defined, in this case .;C:\Sun\AppServer\lib\javaee.jar;C:\Java\lib\mysql.jar;,


Just an side, but setting the CLASSPATH env var globally is a very bad idea. At some point some Java code will break and you will spend countless hours tracking down the issue only to find out that is was because you set CLASSPATH globally and the Java app was therefore picking up the wrong classes.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Peter Johnson wrote:
Just an side, but setting the CLASSPATH env var globally is a very bad idea. At some point some Java code will break and you will spend countless hours tracking down the issue only to find out that is was because you set CLASSPATH globally and the Java app was therefore picking up the wrong classes.



Thank you for the information Peter, and for saving me countless future hours. I have removed the classpath from my environment variables.

I have been wondering, and perhaps you could answer, how to deploy and use my war and jar files.

I'm working on a Tomcat application.

Would it be best to deploy my jar files for db connections to $CATALINA_HOME\lib and then use $CATALINA_HOME\lib for my classpath, or some other configuration?

Thank you for your time.

Lou
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually it is best to place your JAR files in WEB-INF/lib in your WAR file.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see Peter, thank you!

I think adding a lib folder to my eclipse workspace and keeping my jar files there would be a good centralized place for them.

The eclipse project would then use the jar files, and then I have a good reference for building my war files.

Trying to keep things nice and neat, and organized, ... and simple.

Thank You for your time Peter!
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at Maven? It is very good at organizing and maintaining JAR files, and it removes the need to clutter up your Eclipse projects with lib directories containing JAR files. Especially handy if you have multiple projects and they all use very similar sets of JARs.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic