-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdot_bash_java
More file actions
40 lines (35 loc) · 1.17 KB
/
dot_bash_java
File metadata and controls
40 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# If JAVA_HOME is not set try /usr/libexec/java_home to set default
if [ -z "${JAVA_HOME}" ]
then
# See if we can auto-determine the available default for JAVA_HOME
if [ -x /usr/libexec/java_home ]
then
export JAVA_HOME=$(/usr/libexec/java_home)
fi
fi
# If jEnv (https://github.com/jenv/jenv) is installed, initialise it
if [ ! -z "`which jenv`" ] && [ -x "`which jenv`" ]
then
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
jenv enable-plugin maven
jenv enable-plugin springboot
jenv enable-plugin groovy
# Note: this will override JAVA_HOME, which might have been set earlier
jenv enable-plugin export
# Attempt to find all potential JAVA_HOME values for jEnv
if [ -x /usr/libexec/java_home ]
then
num_java_homes=$(/usr/libexec/java_home -X | xmllint --xpath 'count(//dict/string[3]/text())' -)
if [ -n "${num_java_homes}" ]
then
for ((i=1 ; $i <= $num_java_homes ; i++))
do
java_home=$(/usr/libexec/java_home -X | xmllint --xpath "//dict[${i}]/string[3]/text()" -)
echo $java_home
jenv add "${java_home}"
done
fi
# Now you can use "jenv versions" to see available Java versions
fi
fi