Summary: | JAVA_HOME incorrectly defined in ant shell script for Mac OS X 10.7 (Lion) | ||
---|---|---|---|
Product: | Ant | Reporter: | ashirazi |
Component: | Wrapper scripts | Assignee: | Ant Notifications List <notifications> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 1.8.2 | ||
Target Milestone: | 1.9.0 | ||
Hardware: | Macintosh | ||
OS: | other |
Description
ashirazi
2012-02-09 17:12:39 UTC
If the ant script must set a JAVA_HOME, I would suggest basing it on the calculated JAVACMD. For example: if [ -L "$JAVACMD" ]; then JAVA_HOME=`readlink "$JAVACMD"`/../..; else JAVA_HOME="$JAVA_CMD"/../..; fi Actually JAVA_HOME on a Mac is set mostly for jikes later down inside the script (just look for the only other place that references darwin). I don't think simply going two levels up from wherever java is locates is going to help, maybe we just don't set JAVA_HOME unless there is an executable java where we expect to find it as well. Where is the java executable in Lion (and where would we find the runtime libs that used to be in /System/Library/Frameworks/JavaVM.framework/Classes)? Just checked with a co-worker who is using Lion: /System/Library/Frameworks/JavaVM.framework/Home exists, as does /System/Library/Frameworks/JavaVM.framework/Home/bin/java and the later is executable. I'm puzzled. As for your suggested workaround, I'd rather check whether /System/Library/Frameworks/JavaVM.framework/Home/bin/java is executable before setting JAVA_HOME and not set it at all otherwise. Another co-worker pointed me at http://trac.macports.org/ticket/35786 and http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man1/java_home.1.html Keep in mind that you want to configure JAVA_HOME and JAVACMD using the same mechanisms. JAVA_HOME="`/usr/libexec/java_home`" JAVACMD="$JAVA_HOME/bin/java" or JAVACMD="`which java 2> /dev/null `" JAVA_HOME="$JAVACMD/../.." # Note I have left out logic to identify and follow symlinks here The point is they should be consistent, since the java configured on the path may be different from that configured OS-wide. Oh, and for the record: $ /usr/libexec/java_home /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home This is different from what your colleague has configured. All the more reason to try to derive JAVA_HOME/JAVACMD from a known executable (preferable the one on the PATH). I've ported Tomcat's look up algorithm with svn revision 1434680 |