From 7b1fb161fbafd498ff6aade974334edace7e0d6e Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Wed, 17 Jun 2020 11:26:45 -0400 Subject: [PATCH] updated to use java itself to get JAVA_HOME this is the best approach possible if the desired version of java is already in your path. our previous implementation is a guessing game and is dysfunctional. "is", since it's still in place if the call to java fails. --- scripts/customize/fred/java_profile.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/customize/fred/java_profile.sh b/scripts/customize/fred/java_profile.sh index 92a4f52a..f98030a6 100644 --- a/scripts/customize/fred/java_profile.sh +++ b/scripts/customize/fred/java_profile.sh @@ -22,20 +22,23 @@ function intuition_failure() ############################ -# set some fairly liberal limits for ant. -#no. export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m" - -############################ - # start guessing some settings... +# whatever we figure out, we want to export the java home variable. +export JAVA_HOME + # this bin portion works for most javas... export JAVA_BIN_PIECE=bin -# try using java itself if we can. -#if [ ! -d "$JAVA_HOME" ]; then +# try using java itself to locate the JAVA_HOME if we can. +if [ ! -d "$JAVA_HOME" ]; then + JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 | grep -i java.home | sed -e 's/.*java.home = \(.*\)$/\1/') +fi + +# if that didn't work, then we try a series of random bizarro places where +# we have seen java live before. -#fi +#hmmm: below list is way out of date. we really hope the first attempt above works. if [ ! -d "$JAVA_HOME" ]; then # try a recent version. -- 2.34.1