3 # Author: Chris Koeritz
5 # this script tries to intuit where java is installed on this machine.
7 ############################
9 # this reports when we have totally failed to figure out where a folder
10 # is actually located on the machine.
11 function intuition_failure()
14 echo "Could not intuit '$missing' variable."
15 # remove the variable because its value is busted.
19 ############################
21 # set some fairly liberal limits for ant.
22 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
24 ############################
26 # start guessing some settings...
28 # this bin portion works for most javas...
29 export JAVA_BIN_PIECE=bin
31 if [ ! -d "$JAVA_HOME" ]; then
32 # first try a recent linux version.
33 export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
35 if [ ! -d "$JAVA_HOME" ]; then
36 # try an even more recent version.
37 export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
39 if [ ! -d "$JAVA_HOME" ]; then
40 # try using a windows version.
41 #note: this logic is untested.
42 # probably will break due to space in path issues.
43 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
44 if [ ${#any_there[*]} -gt 0 ]; then
45 (( last = ${#any_there[@]} - 1 ))
46 JAVA_HOME="${any_there[$last]}"
48 if [ ! -d "$JAVA_HOME" ]; then
49 # if no jdk, try a jre.
50 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
51 if [ ${#any_there[*]} -gt 0 ]; then
52 (( last = ${#any_there[@]} - 1 ))
53 JAVA_HOME="${any_there[$last]}"
57 # this should go last, since it changes the bin dir.
58 if [ ! -d "$JAVA_HOME" ]; then
59 # if that didn't work, try the location for mac os x.
60 JAVA_HOME=/Library/Java/Home
61 JAVA_BIN_PIECE=Commands
63 # last thing is to tell them we couldn't find it.
64 if [ ! -d "$JAVA_HOME" -a -z "$(which java)" ]; then
65 intuition_failure JAVA_HOME
69 ############################
71 # intuit where we have our local eclipse.
72 if [ ! -d "$ECLIPSE_DIR" ]; then
73 export ECLIPSE_DIR=/usr/local/eclipse_jee
75 if [ ! -d "$ECLIPSE_DIR" ]; then
76 ECLIPSE_DIR=$HOME/eclipse
78 if [ ! -d "$ECLIPSE_DIR" ]; then
79 ECLIPSE_DIR=$HOME/apps/eclipse
81 if [ ! -d "$ECLIPSE_DIR" ]; then
82 #uhhh, default on winders?
83 ECLIPSE_DIR="/c/Program Files/eclipse"
85 if [ ! -d "$ECLIPSE_DIR" ]; then
86 ECLIPSE_DIR="/c/tools/eclipse"
88 if [ ! -d "$ECLIPSE_DIR" ]; then
89 ECLIPSE_DIR="/d/tools/eclipse"
91 if [ ! -d "$ECLIPSE_DIR" ]; then
92 ECLIPSE_DIR="/e/tools/eclipse"
94 # final option is to whine.
95 if [ ! -d "$ECLIPSE_DIR" -a -z "$(which eclipse)" ]; then
96 intuition_failure ECLIPSE_DIR
99 ############################
101 # use the variables we just set in our path, and try to make them override
102 # any other paths to different versions.
104 if [ ! -z "$JAVA_HOME" ]; then
105 export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
107 if [ ! -z "$ECLIPSE_DIR" ]; then
108 export PATH=$ECLIPSE_DIR:$PATH
111 ############################