From ca865c4de063c5b86c5d46a95b5a0ab415235c9e Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 7 Jun 2022 19:25:33 +0100 Subject: added default jvm script --- src/default-jvm.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 src/default-jvm.sh (limited to 'src') diff --git a/src/default-jvm.sh b/src/default-jvm.sh new file mode 100755 index 0000000..96f4f68 --- /dev/null +++ b/src/default-jvm.sh @@ -0,0 +1,49 @@ +#!/bin/sh +JVM_DIR=/usr/lib/jvm +JAVA_BIN=/bin/java + +usage () { + cat << EOF +xilinux-java + Print the name of the currently linked jvm + non-zero exit code if none is linked + +xilinux-java [name] + create symlinks to /usr/lib/jvm/[name]/bin to /bin + +xilinux-java [-l] + list installed JVMs +EOF +} + +get () { + [ -h "$JAVA_BIN" ] && { + path=$(readlink "$JAVA_BIN") + path=${path%%/bin/java} + path=${path##*/} + echo $path + } +} + +link () { + [ -d "$1" ] && for bin in $1/bin/*; do + ln -sf $bin /bin/${bin##*/} + done +} + + +[ "$#" = "0" ] && { + get || return 1 +} || { + case "$1" in + "-l"|"--list") + ls -1 $JVM_DIR + ;; + *) + link $1 \ + || link $JVM_DIR/$1 \ + || get + ;; + esac +} + -- cgit v1.2.1