• 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

Adding Enviroment variable using ANT

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can someone tell me how can I add an enviroment variable such as JAVA_HOME using ANT? or adding paths to Enviroment variables PATH and CLASSPATH?
Should it be different under windows and linux?
I am currently using a batch file that calls setx.exe and I don't want to use batch files.
Please advise
Thanks
Yossi
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you need to set them for? Are you aware of the nested "env" element of both the "java" and "exec" task?
 
garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Yes I'm aware of the env tag but its temporarly variable and I need to set a constant enviroment variable of the pc, or maybe I'm wrong?
Yours
Yossi
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't tell before you answer my first question...
 
garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am building an installation tool (izpack) and it runs ANT.
The installation is for pc's that have no JAVA_HOME variable and I need to set the path and classpath as well.
I have a batch file that I run that uses setx.exe that does all that but It wont run under linux.
The installation procces should be done on windows and linux os.
I hope that answers your question
Thanks
Yossi
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you want to use an ant set of tasks to set the claspath and other env variables correct?

You are going to have different tasks depending upon whether its windows OS or Linux and then probably soem fine grain of that depending upon OS variants for example Windwos: winXPPro or win2kpro or etc..

Probably the best way is to do this:

windowsOS.properties
linuxOS.properties

then you could read the properties in and call the approaite shell exe and pass the vars to accomplish it..

So basicaly yoru set of ant tasks doignthis become your batch file..



Re,ebr ther are certain OSes that stil goof up the env. designation depeing upon which ANT version you are using.. the main Winods and lInux varianst should be ifne but you still should check that behavior on yoru traget OSes..

There are 2 major ANT Books that mya have the Linux part described..

Or do a google search and you should find some ntoes on how to accomplish the goal..
 
garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks mate you gave me real help.
Thank you
Yossi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic