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 # start guessing some settings...
27 # whatever we figure out, we want to export the java home variable.
30 # this bin portion works for most javas...
31 export JAVA_BIN_PIECE=bin
33 # try using java itself to locate the JAVA_HOME if we can.
34 if [ ! -d "$JAVA_HOME" ]; then
35 JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 | grep -i java.home | sed -e 's/.*java.home = \(.*\)$/\1/')
38 # if that didn't work, then we try a series of random bizarro places where
39 # we have seen java live before.
41 #hmmm: below list is way out of date. we really hope the first attempt above works.
43 if [ ! -d "$JAVA_HOME" ]; then
44 # try a recent version.
45 export JAVA_HOME=/usr/lib/jvm/java-8-oracle
47 if [ ! -d "$JAVA_HOME" ]; then
48 # or an older version.
49 export JAVA_HOME=/usr/lib/jvm/java-7-oracle
51 if [ ! -d "$JAVA_HOME" ]; then
52 JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
54 if [ ! -d "$JAVA_HOME" ]; then
55 JAVA_HOME="$(ls -d "c:/Program Files"/*jdk* 2>/dev/null)"
57 if [ ! -d "$JAVA_HOME" ]; then
58 JAVA_HOME="$(ls -d "c:/Program Files (x86)"/*jdk* 2>/dev/null)"
60 if [ ! -d "$JAVA_HOME" ]; then
61 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
62 # try using a windows version.
63 JAVA_HOME="$(ls -d d:/tools/*jdk* 2>/dev/null)"
66 # this should go last, since it changes the bin dir.
67 if [ ! -d "$JAVA_HOME" ]; then
68 # if that didn't work, try the location for mac os x.
69 JAVA_HOME=/Library/Java/Home
70 JAVA_BIN_PIECE=Commands
72 # last thing is to tell them we couldn't find it.
73 if [ ! -d "$JAVA_HOME" ]; then
76 if [ -z "$(whichable java)" ]; then
77 intuition_failure JAVA_HOME
81 ############################
83 # intuit where we have our local eclipse.
84 if [ ! -d "$ECLIPSE_DIR" ]; then
85 export ECLIPSE_DIR=/usr/local/eclipse
87 if [ ! -d "$ECLIPSE_DIR" ]; then
88 ECLIPSE_DIR=$HOME/eclipse
90 if [ ! -d "$ECLIPSE_DIR" ]; then
91 ECLIPSE_DIR=/usr/local/fred/eclipse
93 if [ ! -d "$ECLIPSE_DIR" ]; then
94 ECLIPSE_DIR="c:/tools/eclipse"
96 if [ ! -d "$ECLIPSE_DIR" ]; then
97 if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
98 ECLIPSE_DIR="d:/tools/eclipse"
101 if [ ! -d "$ECLIPSE_DIR" ]; then
102 if [ ! -z "$(grep -i 'e:' /proc/mounts 2>/dev/null)" ]; then
103 ECLIPSE_DIR="e:/tools/eclipse"
106 # final option is to whine.
107 if [ ! -d "$ECLIPSE_DIR" ]; then
110 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
111 # fix the path for cygwin's bizarre requirement of /cygdrive/X.
112 ECLIPSE_DIR=$(echo $ECLIPSE_DIR | sed -e 's/^\(.\):/\/cygdrive\/\1/')
115 if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse)" ]; then
116 intuition_failure ECLIPSE_DIR
119 ############################
121 # use the variables we just set in our path, and try to make them override
122 # any other paths to different versions.
124 if [ ! -z "$JAVA_HOME" ]; then
126 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
127 j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
129 export PATH=$j/$JAVA_BIN_PIECE:$PATH
131 if [ ! -z "$ECLIPSE_DIR" ]; then
133 if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
134 e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
139 ############################
141 #echo "java_profile: JAVA_HOME='$JAVA_HOME' ECLIPSE_DIR='$ECLIPSE_DIR'"