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