I am having a problem running Ant with JDK 1.6 on Mac OS X. Even though Java application versions is set to Java SE 6 in OS X's Java Preference, executing java -version
in Terminal also shows java version "1.6.0_07"
, Ant still seems to use JDK 1.5 to be using JDK 1.5 as it does not see JDK 1.6 classes when compiling my code.
I understand that Ant relies on JAVA_HOME
environment variable to specify which JDK to use. However, I do not quite understand how this variable can be set on Mac OS X.
Hence, my question is how to make Ant runs with JDK 1.6 on Mac OS X. If the correct way is still to set JAVA_HOME
environment variable, how to set the variable on OS X.
The JAVA_HOME environment variable is set in your home directory's .profile file. (/Users/ejel/.profile ?) Edit it and set it to what you want it to be. E.g.:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
From this point onward, every time you open a new terminal window it will have JAVA_HOME set to this new value. It will not have changed with any existing open windows.
If you are truly aghast to putting this in the profile, or if it conflicts with other software, the export statement could always be run in the terminal manually or go into a script (eg: setj6ev.sh) that is run once before you start running ant tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With