# Need to be in the folder containing a compiled-up search4j # If a search4j executable is not there, then it means this is an SVN checkout. # In such a case, it's up to the user checking things out to ensure JAVA_HOME # is set and that it moreover points to the correct version of the Java. # Function to check if any JAVA_HOME is set and if so, try using that function try_java { MIN_DISPLAY_VERSION=${1}; if [ "x$JAVA_HOME" = "x" -o ! -f "$JAVA_HOME/bin/java" ]; then no_java "$MIN_DISPLAY_VERSION" return $? else # There is a JAVA_HOME already set, we're going to try using that javapath="$JAVA_HOME/bin/java" javahome="$JAVA_HOME" # Print a warning that we're going to use whatever JAVA_HOME is set (fingers crossed) if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then echo echo "***************************************************************************" echo "WARNING: " echo "Java Runtime not bundled with this $PROGNAME installation." echo "Using JAVA_HOME: $JAVA_HOME" echo "(NOTE: this needs to be $MIN_DISPLAY_VERSION or higher.)" echo "***************************************************************************" echo fi echo "Java:" echo $javapath echo return 0 fi } function no_java { MIN_DISPLAY_VERSION=${1}; echo if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then echo "Failed to locate an appropriate version of Java. You must install a" echo "Java Runtime Environment (version $MIN_DISPLAY_VERSION or greater) before running the" echo "$PROGNAME." echo "If you have Java installed on your machine please set the environment variable JAVA_HOME." fi return 1 } function set_java_exec { SEARCH4J_EXECUTABLE=${1}; MINIMUM_JAVA_VERSION=${2}; MIN_DISPLAY_VERSION=${3}; # Give search4j a hint to find Java depending on the platform if [ "$EXPEDITEE_OS" = "linux" ]; then HINT=`cd "$EXPEDITEE_HOME";pwd`/packages/jre elif [ "$EXPEDITEE_OS" = "darwin" ]; then HINT=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home #/System/Library/Frameworks/JavaVM.framework/Home fi javapath="`"$SEARCH4J_EXECUTABLE" -e -p "$HINT" -m $MINIMUM_JAVA_VERSION`" javahome="`"$SEARCH4J_EXECUTABLE" -p "$HINT" -m $MINIMUM_JAVA_VERSION`" if [ "$?" != "0" ]; then OLDVER="`"$SEARCH4J_EXECUTABLE" -v -p "$HINT"`" if [ "$?" = "0" ]; then if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then echo "The version of the Java Runtime Environment you have installed ($OLDVER)" echo "is too old to run the $PROGNAME. Please install a new" echo "version of the JRE (version $MIN_DISPLAY_VERSION or newer) and rerun this script." fi return 1 else no_java "$MIN_DISPLAY_VERSION" return $? fi fi echo "Java:" echo $javapath echo return 0 } ## ---- Check Java ---- # Some users may set this line manually javahome= exp_lang=$1 PROGNAME=$2 MINIMUM_JAVA_VERSION=1.8.0_00 MIN_DISPLAY_VERSION=1.8 if [ "x$javahome" != "x" ]; then JAVA_HOME=$javahome; try_java "$MIN_DISPLAY_VERSION" retval=$? return $retval fi # sus out search4j # first look for compiled search4j executable inside the current folder if [ -x "search4j" ]; then SEARCH4J_EXECUTABLE="./search4j" elif [ -x "$EXPEDITEE_HOME/bin/search4j" ]; then SEARCH4J_EXECUTABLE="$EXPEDITEE_HOME/bin/search4j" else echo "Couldn't determine the location of the search4j executable" echo "If you are running Expeditee" echo " * check EXPEDITEE_HOME is set" echo " * check bin/search4j exists" echo " * check bin/search4j is executable" fi # Now run set_java_exec with search4j if we found one, else try javahome if [ "x$SEARCH4J_EXECUTABLE" != "x" ]; then set_java_exec "$SEARCH4J_EXECUTABLE" "$MINIMUM_JAVA_VERSION" "$MIN_DISPLAY_VERSION" retval=$? else try_java "$MIN_DISPLAY_VERSION" retval=$? fi return $retval