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 if [ ! -d "$JAVA_HOME" ]; then
36 # try a recent version.
37 export JAVA_HOME=/usr/lib/jvm/java-8-oracle
39 if [ ! -d "$JAVA_HOME" ]; then
40 # or an older version.
41 export JAVA_HOME=/usr/lib/jvm/java-7-oracle
43 if [ ! -d "$JAVA_HOME" ]; then
44 JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
46 if [ ! -d "$JAVA_HOME" ]; then
47 JAVA_HOME="$(ls -d "c:/Program Files"/*jdk* 2>/dev/null)"
49 if [ ! -d "$JAVA_HOME" ]; then
50 JAVA_HOME="$(ls -d "c:/Program Files (x86)"/*jdk* 2>/dev/null)"
52 if [ ! -d "$JAVA_HOME" ]; then
53 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
54 # try using a windows version.
55 JAVA_HOME="$(ls -d d:/tools/*jdk* 2>/dev/null)"
58 # this should go last, since it changes the bin dir.
59 if [ ! -d "$JAVA_HOME" ]; then
60 # if that didn't work, try the location for mac os x.
61 JAVA_HOME=/Library/Java/Home
62 JAVA_BIN_PIECE=Commands
64 # last thing is to tell them we couldn't find it.
65 if [ ! -d "$JAVA_HOME" ]; then
68 if [ -z "$(whichable java 2>/dev/null)" ]; then
69 intuition_failure JAVA_HOME
73 ############################
75 # intuit where we have our local eclipse.
76 if [ ! -d "$ECLIPSE_DIR" ]; then
77 export ECLIPSE_DIR=/usr/local/eclipse
79 if [ ! -d "$ECLIPSE_DIR" ]; then
80 ECLIPSE_DIR=$HOME/eclipse
82 if [ ! -d "$ECLIPSE_DIR" ]; then
83 ECLIPSE_DIR=/usr/local/fred/eclipse
85 if [ ! -d "$ECLIPSE_DIR" ]; then
86 ECLIPSE_DIR="c:/tools/eclipse"
88 if [ ! -d "$ECLIPSE_DIR" ]; then
89 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
90 ECLIPSE_DIR="d:/tools/eclipse"
93 if [ ! -d "$ECLIPSE_DIR" ]; then
94 if [ ! -z "$(grep -i 'e:' /proc/mounts 2>/dev/null)" ]; then
95 ECLIPSE_DIR="e:/tools/eclipse"
98 # final option is to whine.
99 if [ ! -d "$ECLIPSE_DIR" ]; then
102 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
103 # fix the path for cygwin's bizarre requirement of /cygdrive/X.
104 ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
107 if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
108 intuition_failure ECLIPSE_DIR
111 ############################
113 # use the variables we just set in our path, and try to make them override
114 # any other paths to different versions.
116 if [ ! -z "$JAVA_HOME" ]; then
118 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
119 j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
121 export PATH=$j/$JAVA_BIN_PIECE:$PATH
123 if [ ! -z "$ECLIPSE_DIR" ]; then
125 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
126 e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
131 ############################
133 #echo "java_profile: JAVA_HOME='$JAVA_HOME' ECLIPSE_DIR='$ECLIPSE_DIR'"