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 export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
36 if [ ! -d "$JAVA_HOME" ]; then
37 # try using a windows version.
38 #note: this logic is untested.
39 # probably will break due to space in path issues.
40 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
41 if [ ${#any_there[*]} -gt 0 ]; then
42 (( last = ${#any_there[@]} - 1 ))
43 JAVA_HOME="${any_there[$last]}"
45 if [ ! -d "$JAVA_HOME" ]; then
46 # if no jdk, try a jre.
47 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
48 if [ ${#any_there[*]} -gt 0 ]; then
49 (( last = ${#any_there[@]} - 1 ))
50 JAVA_HOME="${any_there[$last]}"
54 # this should go last, since it changes the bin dir.
55 if [ ! -d "$JAVA_HOME" ]; then
56 # if that didn't work, try the location for mac os x.
57 JAVA_HOME=/Library/Java/Home
58 JAVA_BIN_PIECE=Commands
60 # last thing is to tell them we couldn't find it.
61 if [ ! -d "$JAVA_HOME" ]; then
62 intuition_failure JAVA_HOME
66 ############################
68 # intuit where we have our local eclipse.
69 if [ ! -d "$ECLIPSE_DIR" ]; then
70 export ECLIPSE_DIR=/usr/local/eclipse_jee
72 if [ ! -d "$ECLIPSE_DIR" ]; then
73 ECLIPSE_DIR=$HOME/eclipse
75 if [ ! -d "$ECLIPSE_DIR" ]; then
76 ECLIPSE_DIR=$HOME/apps/eclipse
78 if [ ! -d "$ECLIPSE_DIR" ]; then
79 #uhhh, default on winders?
80 ECLIPSE_DIR="/c/Program Files/eclipse"
82 if [ ! -d "$ECLIPSE_DIR" ]; then
83 ECLIPSE_DIR="/c/tools/eclipse"
85 if [ ! -d "$ECLIPSE_DIR" ]; then
86 ECLIPSE_DIR="/d/tools/eclipse"
88 if [ ! -d "$ECLIPSE_DIR" ]; then
89 ECLIPSE_DIR="/e/tools/eclipse"
91 # final option is to whine.
92 if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
94 ############################
96 # use the variables we just set in our path, and try to make them override
97 # any other paths to different versions.
99 if [ ! -z "$JAVA_HOME" ]; then
100 export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
102 if [ ! -z "$ECLIPSE_DIR" ]; then
103 export PATH=$ECLIPSE_DIR:$PATH
106 ############################