• 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

Access ANT properties in Java program

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

I want to access ant properties which are declared in various targets in the program from my java program. Is this possible? If so can someone please tell me how?

Thanks
Raj
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A few more details about what you're trying to do and what hasn't worked might be helpful.

But I'll assume you are using the java task. Are you trying to pass in command-line arguments or access the ant properties like system properties or ?

The ant manual on Java Task indicates you can use nested arg, jvmarg, sysproperty, and syspropertyset elements with the java task.

If you have a bunch of properties defined elsewhere in your build file and you want to access them like system properties it sounds like the syspropertyset might handle that (syspropertyset is a PropertySet Type)
[ March 15, 2005: Message edited by: Carol Enderlin ]
 
Raj Maheshwari
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carol!

Thanks a lot. Thats exactly what I'm trying to do:
I set a few properties in my build file. I want my java program at runtime to pick up those properties (just like it can pick up system properties). I'll give this a shot today.

Raj
 
Raj Maheshwari
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carol!

Your suggestion did solve a part of my problem - calling it from the Java Task when. However, I still have a problem if my program runs from within a web application. How can it pick up properties at that point?

Thanks
Raj
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the "simple" answer to your question is to pass them in on the command-line.

java -Dprop.name=value ...

There are other ways to deal with properties, though. Such as properties files. e.g. lots of hit on google, Loading properties article

Perhaps this isn't really an ant question at all.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic