source: trunk/in-the-cloud/findjava.sh

Last change on this file was 1071, checked in by davidb, 8 years ago

Set of files to make it easier to launch Expeditee using an in-the-cloud storage system such as Google Drive. First cut works for Windows

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1# Need to be in the folder containing a compiled-up search4j
2# If a search4j executable is not there, then it means this is an SVN checkout.
3# In such a case, it's up to the user checking things out to ensure JAVA_HOME
4# is set and that it moreover points to the correct version of the Java.
5
6# Function to check if any JAVA_HOME is set and if so, try using that
7function try_java {
8 MIN_DISPLAY_VERSION=${1};
9
10 if [ "x$JAVA_HOME" = "x" -o ! -f "$JAVA_HOME/bin/java" ]; then
11 no_java "$MIN_DISPLAY_VERSION"
12 return $?
13 else
14 # There is a JAVA_HOME already set, we're going to try using that
15 javapath="$JAVA_HOME/bin/java"
16 javahome="$JAVA_HOME"
17 # Print a warning that we're going to use whatever JAVA_HOME is set (fingers crossed)
18 if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then
19 echo
20 echo "***************************************************************************"
21 echo "WARNING: "
22 echo "Java Runtime not bundled with this $PROGNAME installation."
23 echo "Using JAVA_HOME: $JAVA_HOME"
24 echo "(NOTE: this needs to be $MIN_DISPLAY_VERSION or higher.)"
25 echo "***************************************************************************"
26 echo
27 fi
28 echo "Java:"
29 echo $javapath
30 echo
31 return 0
32 fi
33}
34
35function no_java {
36 MIN_DISPLAY_VERSION=${1};
37
38 echo
39 if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then
40 echo "Failed to locate an appropriate version of Java. You must install a"
41 echo "Java Runtime Environment (version $MIN_DISPLAY_VERSION or greater) before running the"
42 echo "$PROGNAME."
43 echo "If you have Java installed on your machine please set the environment variable JAVA_HOME."
44 fi
45 return 1
46}
47
48function set_java_exec {
49 SEARCH4J_EXECUTABLE=${1};
50 MINIMUM_JAVA_VERSION=${2};
51 MIN_DISPLAY_VERSION=${3};
52
53 # Give search4j a hint to find Java depending on the platform
54 if [ "$EXPEDITEE_OS" = "linux" ]; then
55 HINT=`cd "$EXPEDITEE_HOME";pwd`/packages/jre
56 elif [ "$EXPEDITEE_OS" = "darwin" ]; then
57 HINT=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
58 #/System/Library/Frameworks/JavaVM.framework/Home
59 fi
60
61 javapath="`"$SEARCH4J_EXECUTABLE" -e -p "$HINT" -m $MINIMUM_JAVA_VERSION`"
62 javahome="`"$SEARCH4J_EXECUTABLE" -p "$HINT" -m $MINIMUM_JAVA_VERSION`"
63
64 if [ "$?" != "0" ]; then
65
66 OLDVER="`"$SEARCH4J_EXECUTABLE" -v -p "$HINT"`"
67
68 if [ "$?" = "0" ]; then
69
70 if [ "x$exp_lang" = "x" -o "$exp_lang" = "en" ]; then
71 echo "The version of the Java Runtime Environment you have installed ($OLDVER)"
72 echo "is too old to run the $PROGNAME. Please install a new"
73 echo "version of the JRE (version $MIN_DISPLAY_VERSION or newer) and rerun this script."
74 fi
75 return 1
76
77 else
78 no_java "$MIN_DISPLAY_VERSION"
79 return $?
80 fi
81
82 fi
83 echo "Java:"
84 echo $javapath
85 echo
86 return 0
87}
88
89
90## ---- Check Java ----
91# Some users may set this line manually
92javahome=
93exp_lang=$1
94PROGNAME=$2
95MINIMUM_JAVA_VERSION=1.8.0_00
96MIN_DISPLAY_VERSION=1.8
97if [ "x$javahome" != "x" ]; then
98 JAVA_HOME=$javahome;
99 try_java "$MIN_DISPLAY_VERSION"
100 retval=$?
101 return $retval
102fi
103
104# sus out search4j
105# first look for compiled search4j executable inside the current folder
106if [ -x "search4j" ]; then
107 SEARCH4J_EXECUTABLE="./search4j"
108elif [ -x "$EXPEDITEE_HOME/bin/search4j" ]; then
109 SEARCH4J_EXECUTABLE="$EXPEDITEE_HOME/bin/search4j"
110else
111 echo "Couldn't determine the location of the search4j executable"
112 echo "If you are running Expeditee"
113 echo " * check EXPEDITEE_HOME is set"
114 echo " * check bin/search4j exists"
115 echo " * check bin/search4j is executable"
116fi
117
118# Now run set_java_exec with search4j if we found one, else try javahome
119if [ "x$SEARCH4J_EXECUTABLE" != "x" ]; then
120 set_java_exec "$SEARCH4J_EXECUTABLE" "$MINIMUM_JAVA_VERSION" "$MIN_DISPLAY_VERSION"
121 retval=$?
122else
123 try_java "$MIN_DISPLAY_VERSION"
124 retval=$?
125fi
126return $retval
Note: See TracBrowser for help on using the repository browser.