3 # Author: Chris Koeritz
5 # this script tries to intuit where java is installed on this machine.
7 ############################
9 function intuition_failure()
12 echo "We cannot intuit your $missing variable for this host."
13 # remove the variable because its value is busted.
17 ############################
19 # set some fairly liberal limits for ant.
20 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
22 ############################
24 # start guessing some settings...
26 # this bin portion works for most javas...
27 export JAVA_BIN_PIECE=bin
29 if [ ! -d "$JAVA_HOME" ]; then
30 # first try a recent linux version.
31 export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
33 if [ ! -d "$JAVA_HOME" ]; then
34 # try an even more recent version.
35 export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
37 if [ ! -d "$JAVA_HOME" ]; then
38 # try using a windows version.
39 #note: this logic is untested.
40 # probably will break due to space in path issues.
41 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
42 if [ ${#any_there[*]} -gt 0 ]; then
43 (( last = ${#any_there[@]} - 1 ))
44 JAVA_HOME="${any_there[$last]}"
46 if [ ! -d "$JAVA_HOME" ]; then
47 # if no jdk, try a jre.
48 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
49 if [ ${#any_there[*]} -gt 0 ]; then
50 (( last = ${#any_there[@]} - 1 ))
51 JAVA_HOME="${any_there[$last]}"
55 # this should go last, since it changes the bin dir.
56 if [ ! -d "$JAVA_HOME" ]; then
57 # if that didn't work, try the location for mac os x.
58 JAVA_HOME=/Library/Java/Home
59 JAVA_BIN_PIECE=Commands
61 # last thing is to tell them we couldn't find it.
62 if [ ! -d "$JAVA_HOME" ]; then
63 if [ ! -z "$(which java)" ]; then
64 echo "JAVA_HOME unknown, but java is in path."
66 intuition_failure JAVA_HOME
71 ############################
73 # intuit where we have our local eclipse.
74 if [ ! -d "$ECLIPSE_DIR" ]; then
75 export ECLIPSE_DIR=/usr/local/eclipse_jee
77 if [ ! -d "$ECLIPSE_DIR" ]; then
78 ECLIPSE_DIR=$HOME/eclipse
80 if [ ! -d "$ECLIPSE_DIR" ]; then
81 ECLIPSE_DIR=$HOME/apps/eclipse
83 if [ ! -d "$ECLIPSE_DIR" ]; then
84 #uhhh, default on winders?
85 ECLIPSE_DIR="/c/Program Files/eclipse"
87 if [ ! -d "$ECLIPSE_DIR" ]; then
88 ECLIPSE_DIR="/c/tools/eclipse"
90 if [ ! -d "$ECLIPSE_DIR" ]; then
91 ECLIPSE_DIR="/d/tools/eclipse"
93 if [ ! -d "$ECLIPSE_DIR" ]; then
94 ECLIPSE_DIR="/e/tools/eclipse"
96 # final option is to whine.
97 if [ ! -d "$ECLIPSE_DIR" ]; then
98 if [ ! -z "$(which eclipse)" ]; then
99 echo "ECLIPSE_DIR unknown, but eclipse is in path."
101 intuition_failure ECLIPSE_DIR;
105 ############################
107 # use the variables we just set in our path, and try to make them override
108 # any other paths to different versions.
110 if [ ! -z "$JAVA_HOME" ]; then
111 export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
113 if [ ! -z "$ECLIPSE_DIR" ]; then
114 export PATH=$ECLIPSE_DIR:$PATH
117 ############################