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
11 # this reports when we have totally failed to figure out where a folder
12 # is actually located on the machine.
13 function intuition_failure()
16 if [ ! -z "$SHELL_DEBUG" ]; then
17 echo "Could not intuit '$missing' variable."
19 # remove the variable because its value is busted.
23 ############################
25 # set some fairly liberal limits for ant.
26 export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
28 ############################
30 # start guessing some settings...
32 # this bin portion works for most javas...
33 export JAVA_BIN_PIECE=bin
35 if [ ! -d "$JAVA_HOME" ]; then
36 # try a recent version.
37 export JAVA_HOME=/usr/lib/jvm/java-7-oracle
39 if [ ! -d "$JAVA_HOME" ]; then
40 JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
42 if [ ! -d "$JAVA_HOME" ]; then
43 JAVA_HOME="$(ls -d "c:/Program Files"/*jdk* 2>/dev/null)"
45 if [ ! -d "$JAVA_HOME" ]; then
46 JAVA_HOME="$(ls -d "c:/Program Files (x86)"/*jdk* 2>/dev/null)"
48 if [ ! -d "$JAVA_HOME" ]; then
49 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
50 # try using a windows version.
51 JAVA_HOME="$(ls -d d:/tools/*jdk* 2>/dev/null)"
54 # this should go last, since it changes the bin dir.
55 if [ ! -d "$JAVA_HOME" ]; then
56 # if that didn't work, try the location for mac os x.
57 JAVA_HOME=/Library/Java/Home
58 JAVA_BIN_PIECE=Commands
60 # last thing is to tell them we couldn't find it.
61 if [ ! -d "$JAVA_HOME" ]; then
64 if [ -z "$(whichable java 2>/dev/null)" ]; 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
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 ECLIPSE_DIR="c:/tools/eclipse"
84 if [ ! -d "$ECLIPSE_DIR" ]; then
85 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
86 ECLIPSE_DIR="d:/tools/eclipse"
89 if [ ! -d "$ECLIPSE_DIR" ]; then
90 if [ ! -z "$(grep -i 'e:' /proc/mounts 2>/dev/null)" ]; then
91 ECLIPSE_DIR="e:/tools/eclipse"
94 # final option is to whine.
95 if [ ! -d "$ECLIPSE_DIR" ]; then
98 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
99 # fix the path for cygwin's bizarre requirement of /cygdrive/X.
100 ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
103 if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
104 intuition_failure ECLIPSE_DIR
107 ############################
109 # use the variables we just set in our path, and try to make them override
110 # any other paths to different versions.
112 if [ ! -z "$JAVA_HOME" ]; then
114 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
115 j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
117 export PATH=$j/$JAVA_BIN_PIECE:$PATH
119 if [ ! -z "$ECLIPSE_DIR" ]; then
121 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
122 e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
127 ############################
129 #echo "java_profile: JAVA_HOME='$JAVA_HOME' ECLIPSE_DIR='$ECLIPSE_DIR'"