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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Ant set the environment? 1

Status
Not open for further replies.

ThomasChester

Technical User
Feb 24, 2006
1
0
0
US
I've been working with Java-based installers that support calling out to Ant scripts. I use the scripts to configure the installed files, start services, deploy web apps, and various other tasks. The scripts get fairly complicated. I've run into a situation where the environment requires the classpath, path, and other environment variables be set. I understand that Ant is running in a JRE and it's asking a lot for it to reach out and change the path, but if it can copy a file...

Probably ignorance on my part, but an explanation would be appreciated. An Ant solution would be REALLY appreciated.

Thanks,
Tom
 
You can use the ANT "EXEC" task to run a bat/sh script to set paths and classpaths from within an ANT script.
E.G.
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="setjavahome" basedir="." default="main">

<target name="main">
<echo> OSNAME = ${java.home}</echo>
<exec dir="." executable="setjh.bat" />
<echo> OSNAME = ${java.home}</echo>
</target>
</project>

Contents of setjh.bat ********************
set JAVA_HOME=C:\Program Files\Java\jre1.5.0_02
End of Contents of setjh.bat **************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top