Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding Enviroment variable using ANT  RSS feed

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks mate you gave me real help.
Thank you
Yossi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!