Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting environment variables

Status
Not open for further replies.

papakosh

Programmer
Jul 15, 2005
1
US
I'm trying to use ant to set environment variables in windows xp. I have gotten it to set environment variables using setx.exe, but that does not set it for the current command window. I tried calling set but the changes do not seem to be taking to the current window.

Here is the code: (from my install.xml)

<exec executable="cmd" os="Windows XP" input="env_vars1.txt">
</exec>

And inside env_vars1.txt, I am using the set command in the following matter.
set JAVA_HOME=C:\j2sdk1.4.2_06


I've tried using various variations of this (with and without quotes), but nothing takes. It does say it is setting, but nothing takes. And i've copied and pasted that exact command into the command window and windows accepts it....so I am quite positive it is correct.

Anyone have a suggestion? Thanks.
 
New env. variables set in a 'cmd' won't survive beyond the life of that 'cmd' shell. So as soon as your <exec> has finished, the variable is gone. You can try this in the usual Window's cmd shell. Open one and set a variable. Close it, open a new one, and try to echo the value of the variable you just created.

Could you use an Ant 'property' instead?

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top