I do not want to change JAVA_HOME or Path, Classpath etc on the machine since many applications are dependent on it. Is there is a way i can give j2sdk as option within the ant command itself. Please advise
Main Topics
Browse All TopicsHi,
My computer classpath, path etc set up for j2sdk 1.5 to run eclipse 3.4.1. I need to run the ant scripts from command prompt through j2sdk1.4.2.19.
I am giving command like
>>>>ant -buildfile build.xml
which by default run through j2sdk1.5.
How can i change above command or give additional option command to run through j2sdk1.4.2.19.
Any ideas, sample code, resources , links highly appreciated. Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You can set JAVA_HOME locally, in the command prompt. When you do that, it will only affect the current prompt, and nothing else on the machine.
To do so write, in the command prompt
set JAVA_HOME=xxx
You may find it easier to create a batch file to run your ant in jdk 1.4, instead of doing this every time. When you run a batch file the JAVA_HOME will change only for that execution. The batch file will look like this:
@echo off
set JAVA_HOME=xxx
ant ...
Did you write "set D:\Program Files\Java\jdk1.4" or "set JAVA_HOME="D:\Program Files\Java\jdk1.4" "? Be sure to set JAVA_HOME and put the directory in quotes (since it contains a space). After doing it run
echo %JAVA_HOME%
to check the value.
Whatever you do, it won't change the java version you see in "java -version", because that is decided by finding the first "java.exe" in the directories in "PATH" variable. If you want to change that, you need to change the PATH variable using
set PATH="D:\Program Files\Java\jdk1.4\bin"
Business Accounts
Answer for Membership
by: CEHJPosted on 2009-08-18 at 10:47:39ID: 25125703
Just set JAVA_HOME to the 1.4 installation directory. PATH will of course contain %JAVA_HOME%\bin (in Windows)