3 # Author: Chris Koeritz
5 # this script tries to intuit where java is installed on this machine.
7 ############################
9 source $FEISTY_MEOW_SCRIPTS/core/functions.sh
14 # which which &>/dev/null
15 # if [ $? -ne 0 ]; then
16 # # there is no which command here. we produce nothing due to this.
19 # echo $(which $to_find)
22 # this reports when we have totally failed to figure out where a folder
23 # is actually located on the machine.
24 function intuition_failure()
27 if [ ! -z "$SHELL_DEBUG" ]; then
28 echo "Could not intuit '$missing' variable."
30 # remove the variable because its value is busted.
34 ############################
36 # set some fairly liberal limits for ant.
37 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
39 ############################
41 # start guessing some settings...
43 # this bin portion works for most javas...
44 export JAVA_BIN_PIECE=bin
46 if [ ! -d "$JAVA_HOME" ]; then
47 # first try a recent linux version.
48 export JAVA_HOME=/usr/lib/jvm/java-6-sun
50 if [ ! -d "$JAVA_HOME" ]; then
51 # try an even more recent version.
52 export JAVA_HOME=/usr/lib/jvm/java-7-oracle
54 if [ ! -d "$JAVA_HOME" ]; then
55 JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
57 if [ ! -d "$JAVA_HOME" ]; then
58 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
59 # try using a windows version.
60 JAVA_HOME="$(ls -d d:/tools/*jdk* 2>/dev/null)"
63 # this should go last, since it changes the bin dir.
64 if [ ! -d "$JAVA_HOME" ]; then
65 # if that didn't work, try the location for mac os x.
66 JAVA_HOME=/Library/Java/Home
67 JAVA_BIN_PIECE=Commands
69 # last thing is to tell them we couldn't find it.
70 if [ ! -d "$JAVA_HOME" ]; then
73 if [ -z "$(whichable java 2>/dev/null)" ]; then
74 intuition_failure JAVA_HOME
78 ############################
80 # intuit where we have our local eclipse.
81 if [ ! -d "$ECLIPSE_DIR" ]; then
82 export ECLIPSE_DIR=/usr/local/eclipse
84 if [ ! -d "$ECLIPSE_DIR" ]; then
85 ECLIPSE_DIR=$HOME/eclipse
87 if [ ! -d "$ECLIPSE_DIR" ]; then
88 ECLIPSE_DIR=$HOME/apps/eclipse
90 if [ ! -d "$ECLIPSE_DIR" ]; then
91 ECLIPSE_DIR="c:/tools/eclipse"
93 if [ ! -d "$ECLIPSE_DIR" ]; then
94 if [ ! -z "$(grep -i 'd:' /proc/mounts)" ]; then
95 ECLIPSE_DIR="d:/tools/eclipse"
98 if [ ! -d "$ECLIPSE_DIR" ]; then
99 if [ ! -z "$(grep -i 'e:' /proc/mounts)" ]; then
100 ECLIPSE_DIR="e:/tools/eclipse"
103 # final option is to whine.
104 if [ ! -d "$ECLIPSE_DIR" ]; then
107 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
108 # fix the path for cygwin's bizarre requirement of /cygdrive/X.
109 ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
112 if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
113 intuition_failure ECLIPSE_DIR
116 ############################
118 # use the variables we just set in our path, and try to make them override
119 # any other paths to different versions.
121 if [ ! -z "$JAVA_HOME" ]; then
123 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
124 j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
126 export PATH=$j/$JAVA_BIN_PIECE:$PATH
128 if [ ! -z "$ECLIPSE_DIR" ]; then
130 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
131 e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
136 ############################