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 "$DEBUG_FEISTY_MEOW" ]; 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 #no. 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 # try using java itself if we can.
36 #if [ ! -d "$JAVA_HOME" ]; then
40 if [ ! -d "$JAVA_HOME" ]; then
41 # try a recent version.
42 export JAVA_HOME=/usr/lib/jvm/java-8-oracle
44 if [ ! -d "$JAVA_HOME" ]; then
45 # or an older version.
46 export JAVA_HOME=/usr/lib/jvm/java-7-oracle
48 if [ ! -d "$JAVA_HOME" ]; then
49 JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
51 if [ ! -d "$JAVA_HOME" ]; then
52 JAVA_HOME="$(ls -d "c:/Program Files"/*jdk* 2>/dev/null)"
54 if [ ! -d "$JAVA_HOME" ]; then
55 JAVA_HOME="$(ls -d "c:/Program Files (x86)"/*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)" ]; 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=/usr/local/fred/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 2>/dev/null)" ]; then
95 ECLIPSE_DIR="d:/tools/eclipse"
98 if [ ! -d "$ECLIPSE_DIR" ]; then
99 if [ ! -z "$(grep -i 'e:' /proc/mounts 2>/dev/null)" ]; 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)" ]; 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 ############################
138 #echo "java_profile: JAVA_HOME='$JAVA_HOME' ECLIPSE_DIR='$ECLIPSE_DIR'"