3 # Author: Chris Koeritz
5 # this script tries to intuit where java is installed on this machine.
7 ############################
12 which which &>/dev/null
14 # there is no which command here. we produce nothing due to this.
17 echo $(which $to_find)
20 # this reports when we have totally failed to figure out where a folder
21 # is actually located on the machine.
22 function intuition_failure()
25 if [ ! -z "$SHELL_DEBUG" ]; then
26 echo "Could not intuit '$missing' variable."
28 # remove the variable because its value is busted.
32 ############################
34 # set some fairly liberal limits for ant.
35 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
37 ############################
39 # start guessing some settings...
41 # this bin portion works for most javas...
42 export JAVA_BIN_PIECE=bin
44 if [ ! -d "$JAVA_HOME" ]; then
45 # first try a recent linux version.
46 export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
48 if [ ! -d "$JAVA_HOME" ]; then
49 # try an even more recent version.
50 export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
52 if [ ! -d "$JAVA_HOME" ]; then
53 JAVA_HOME="$(ls -d c:/tools/*jdk*)"
55 if [ ! -d "$JAVA_HOME" ]; then
56 if [ ! -z "$(grep 'd:' /proc/mounts)" ]; then
57 # try using a windows version.
58 JAVA_HOME="$(ls -d d:/tools/*jdk*)"
61 # this should go last, since it changes the bin dir.
62 if [ ! -d "$JAVA_HOME" ]; then
63 # if that didn't work, try the location for mac os x.
64 JAVA_HOME=/Library/Java/Home
65 JAVA_BIN_PIECE=Commands
67 # last thing is to tell them we couldn't find it.
68 if [ ! -d "$JAVA_HOME" -a -z "$(whichable java 2>/dev/null)" ]; then
69 intuition_failure JAVA_HOME
74 ############################
76 # intuit where we have our local eclipse.
77 if [ ! -d "$ECLIPSE_DIR" ]; then
78 export ECLIPSE_DIR=/usr/local/eclipse_jee
80 if [ ! -d "$ECLIPSE_DIR" ]; then
81 ECLIPSE_DIR=$HOME/eclipse
83 if [ ! -d "$ECLIPSE_DIR" ]; then
84 ECLIPSE_DIR=$HOME/apps/eclipse
86 if [ ! -d "$ECLIPSE_DIR" ]; then
87 ECLIPSE_DIR="c:/tools/eclipse"
89 if [ ! -d "$ECLIPSE_DIR" ]; then
90 if [ ! -z "$(grep 'd:' /proc/mounts)" ]; then
91 ECLIPSE_DIR="d:/tools/eclipse"
94 if [ ! -d "$ECLIPSE_DIR" ]; then
95 if [ ! -z "$(grep 'e:' /proc/mounts)" ]; then
96 ECLIPSE_DIR="e:/tools/eclipse"
99 # final option is to whine.
100 if [ ! -d "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
101 intuition_failure ECLIPSE_DIR
104 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
105 ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
109 ############################
111 # use the variables we just set in our path, and try to make them override
112 # any other paths to different versions.
114 if [ ! -z "$JAVA_HOME" ]; then
116 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
117 j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
119 export PATH=$PATH:$j/$JAVA_BIN_PIECE
121 if [ ! -z "$ECLIPSE_DIR" ]; then
123 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
124 e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
129 ############################