revised usage of apps dir
[feisty_meow.git] / scripts / customize / fred / java_profile.sh
1 #!/bin/bash
2
3 # Author: Chris Koeritz
4
5 # this script tries to intuit where java is installed on this machine.
6
7 ############################
8
9 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
10
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()
14 {
15   missing="$1"; shift
16   if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
17     echo "Could not intuit '$missing' variable."
18   fi
19   # remove the variable because its value is busted.
20   unset $missing
21 }
22
23 ############################
24
25 # set some fairly liberal limits for ant.
26 #no. export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
27
28 ############################
29
30 # start guessing some settings...
31
32 # this bin portion works for most javas...
33 export JAVA_BIN_PIECE=bin
34
35 if [ ! -d "$JAVA_HOME" ]; then
36   # try a recent version.
37   export JAVA_HOME=/usr/lib/jvm/java-8-oracle
38 fi
39 if [ ! -d "$JAVA_HOME" ]; then
40   # or an older version.
41   export JAVA_HOME=/usr/lib/jvm/java-7-oracle
42 fi
43 if [ ! -d "$JAVA_HOME" ]; then
44   JAVA_HOME="$(ls -d c:/tools/*jdk* 2>/dev/null)"
45 fi
46 if [ ! -d "$JAVA_HOME" ]; then
47   JAVA_HOME="$(ls -d "c:/Program Files"/*jdk* 2>/dev/null)"
48 fi
49 if [ ! -d "$JAVA_HOME" ]; then
50   JAVA_HOME="$(ls -d "c:/Program Files (x86)"/*jdk* 2>/dev/null)"
51 fi
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)"
56   fi
57 fi
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
63 fi
64 # last thing is to tell them we couldn't find it.
65 if [ ! -d "$JAVA_HOME" ]; then
66   unset JAVA_HOME
67   unset JAVA_BIN_PIECE
68   if [ -z "$(whichable java 2>/dev/null)" ]; then
69     intuition_failure JAVA_HOME
70   fi
71 fi
72
73 ############################
74
75 # intuit where we have our local eclipse.
76 if [ ! -d "$ECLIPSE_DIR" ]; then
77   export ECLIPSE_DIR=/usr/local/eclipse
78 fi
79 if [ ! -d "$ECLIPSE_DIR" ]; then
80   ECLIPSE_DIR=$HOME/eclipse
81 fi
82 if [ ! -d "$ECLIPSE_DIR" ]; then
83   ECLIPSE_DIR=/usr/local/fred/eclipse
84 fi
85 if [ ! -d "$ECLIPSE_DIR" ]; then
86   ECLIPSE_DIR="c:/tools/eclipse"
87 fi
88 if [ ! -d "$ECLIPSE_DIR" ]; then
89   if [ ! -z "$(grep -i 'd:' /proc/mounts 2>/dev/null)" ]; then
90     ECLIPSE_DIR="d:/tools/eclipse"
91   fi
92 fi
93 if [ ! -d "$ECLIPSE_DIR" ]; then
94   if [ ! -z "$(grep -i 'e:' /proc/mounts 2>/dev/null)" ]; then
95     ECLIPSE_DIR="e:/tools/eclipse"
96   fi
97 fi
98 # final option is to whine.
99 if [ ! -d "$ECLIPSE_DIR" ]; then
100   unset ECLIPSE_DIR
101 else
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/')
105   fi
106 fi
107 if [ -z "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then
108   intuition_failure ECLIPSE_DIR
109 fi
110
111 ############################
112
113 # use the variables we just set in our path, and try to make them override
114 # any other paths to different versions.
115
116 if [ ! -z "$JAVA_HOME" ]; then
117   j="$JAVA_HOME"
118   if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
119     j=$(echo $j | sed -e 's/^\(.\):/\/cygdrive\/\1/')
120   fi
121   export PATH=$j/$JAVA_BIN_PIECE:$PATH
122 fi
123 if [ ! -z "$ECLIPSE_DIR" ]; then
124   e="$ECLIPSE_DIR"
125   if [ ! -z "$(uname -a | grep -i cygwin)" ]; then
126     e=$(echo $e | sed -e 's/^\(.\):/\/cygdrive\/\1/')
127   fi
128   export PATH=$e:$PATH
129 fi
130
131 ############################
132
133 #echo "java_profile: JAVA_HOME='$JAVA_HOME' ECLIPSE_DIR='$ECLIPSE_DIR'"
134