2 # this script tries to intuit where java is installed on this machine.
4 ############################
6 function intuition_failure()
9 echo "We cannot intuit your $missing variable for this host."
10 # remove the variable because its value is busted.
14 ############################
16 # set some fairly liberal limits for ant.
17 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
19 ############################
21 # start guessing some settings...
23 # this bin portion works for most javas...
24 export JAVA_BIN_PIECE=bin
26 if [ ! -d "$JAVA_HOME" ]; then
27 # first try a recent linux version.
28 export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
30 if [ ! -d "$JAVA_HOME" ]; then
31 # try using a windows version.
32 #note: this logic is untested.
33 # probably will break due to space in path issues.
34 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
35 if [ ${#any_there[*]} -gt 0 ]; then
36 (( last = ${#any_there[@]} - 1 ))
37 JAVA_HOME="${any_there[$last]}"
39 if [ ! -d "$JAVA_HOME" ]; then
40 # if no jdk, try a jre.
41 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
42 if [ ${#any_there[*]} -gt 0 ]; then
43 (( last = ${#any_there[@]} - 1 ))
44 JAVA_HOME="${any_there[$last]}"
48 # this should go last, since it changes the bin dir.
49 if [ ! -d "$JAVA_HOME" ]; then
50 # if that didn't work, try the location for mac os x.
51 JAVA_HOME=/Library/Java/Home
52 JAVA_BIN_PIECE=Commands
54 # last thing is to tell them we couldn't find it.
55 if [ ! -d "$JAVA_HOME" ]; then
56 intuition_failure JAVA_HOME
60 ############################
62 # intuit where we have our local eclipse.
63 if [ ! -d "$ECLIPSE_DIR" ]; then
64 export ECLIPSE_DIR=/usr/local/eclipse_jee
66 if [ ! -d "$ECLIPSE_DIR" ]; then
67 ECLIPSE_DIR=$HOME/eclipse
69 if [ ! -d "$ECLIPSE_DIR" ]; then
70 ECLIPSE_DIR=$HOME/apps/eclipse
72 if [ ! -d "$ECLIPSE_DIR" ]; then
73 #uhhh, default on winders?
74 ECLIPSE_DIR="/c/Program Files/eclipse"
76 if [ ! -d "$ECLIPSE_DIR" ]; then
77 ECLIPSE_DIR="/c/tools/eclipse"
79 if [ ! -d "$ECLIPSE_DIR" ]; then
80 ECLIPSE_DIR="/d/tools/eclipse"
82 if [ ! -d "$ECLIPSE_DIR" ]; then
83 ECLIPSE_DIR="/e/tools/eclipse"
85 # final option is to whine.
86 if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
88 ############################
90 # use the variables we just set in our path, and try to make them override
91 # any other paths to different versions.
93 if [ ! -z "$JAVA_HOME" ]; then
94 export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
96 if [ ! -z "$ECLIPSE_DIR" ]; then
97 export PATH=$ECLIPSE_DIR:$PATH