some packages, most notably, dev-java/ant, provide their own shell script launcher which uses java-config to obtain JAVA_HOME. This is annoying as I cannot simply specify "JAVA_HOME=<path> ant", but instead must use java-config or as I have done, hack the ant launcher to respect the environment and not set JAVA_HOME if its already set. This would be a nice bit of common functionality to extract to a java the java-utils eclass. My hack follows (this is from /usr/bin/ant from dev-java/ant) BEFORE: if [ -f $HOME/.gentoo/java-env ] ; then source $HOME/.gentoo/java-env else JAVA_HOME=`java-config --jdk-home` CLASSPATH=`java-config --classpath`:${CLASSPATH} fi if [ -z $JAVA_HOME ] ; then echo "Error: No JDK found!" echo "Try using java-config script to set your JDK" echo "Remember that you need a JDK not a JRE" exit 1 fi FIX: wrap the above with a conditional "if [ -z $JAVA_HOME ]; then" and respect a previously declared JAVA_HOME Thanks
*** Bug 64282 has been marked as a duplicate of this bug. ***
This seems to have been fixed already. Now, JAVA_HOME will only be defined if it hasn't already been so.