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 if [ ! -z "$SHELL_DEBUG" ]; then
15 echo "Could not intuit '$missing' variable."
17 # remove the variable because its value is busted.
21 ############################
23 # set some fairly liberal limits for ant.
24 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
26 ############################
28 # start guessing some settings...
30 # this bin portion works for most javas...
31 export JAVA_BIN_PIECE=bin
33 if [ ! -d "$JAVA_HOME" ]; then
34 # first try a recent linux version.
35 export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
37 if [ ! -d "$JAVA_HOME" ]; then
38 # try an even more recent version.
39 export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
41 if [ ! -d "$JAVA_HOME" ]; then
42 # try using a windows version.
43 #note: this logic is untested.
44 # probably will break due to space in path issues.
45 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
46 if [ ${#any_there[*]} -gt 0 ]; then
47 (( last = ${#any_there[@]} - 1 ))
48 JAVA_HOME="${any_there[$last]}"
50 if [ ! -d "$JAVA_HOME" ]; then
51 # if no jdk, try a jre.
52 declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
53 if [ ${#any_there[*]} -gt 0 ]; then
54 (( last = ${#any_there[@]} - 1 ))
55 JAVA_HOME="${any_there[$last]}"
59 # this should go last, since it changes the bin dir.
60 if [ ! -d "$JAVA_HOME" ]; then
61 # if that didn't work, try the location for mac os x.
62 JAVA_HOME=/Library/Java/Home
63 JAVA_BIN_PIECE=Commands
65 # last thing is to tell them we couldn't find it.
66 if [ ! -d "$JAVA_HOME" -a -z "$(which java)" ]; then
67 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" -a -z "$(which eclipse)" ]; then
98 intuition_failure ECLIPSE_DIR
101 ############################
103 # use the variables we just set in our path, and try to make them override
104 # any other paths to different versions.
106 if [ ! -z "$JAVA_HOME" ]; then
107 export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
109 if [ ! -z "$ECLIPSE_DIR" ]; then
110 export PATH=$ECLIPSE_DIR:$PATH
113 ############################