Skip to content

Instantly share code, notes, and snippets.

@solidsnack
Created November 20, 2013 19:18
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save solidsnack/7569266 to your computer and use it in GitHub Desktop.
Save solidsnack/7569266 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit -o nounset -o pipefail
function -h {
cat <<USAGE
USAGE: ln_libjvm.bash
Symlink a likely libjvm.so into /usr/bin.
USAGE
}; function --help { -h ;}
export LC_ALL=en_US.UTF-8
function main {
ln_libjvm
}
function ln_libjvm {
# Expand glob to get likely SOs.
local libjvms=( /usr/lib/jvm/java-*-openjdk-*/jre/lib/*/server/libjvm.so )
if [[ -f ${libjvms[0]} ]]
then sudo ln -nsf "${libjvms[0]}" /usr/lib/libjvm.so
else err "Not a file: ${libjvms[0]}"
fi
}
function msg { out "$*" >&2 ;}
function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;}
function out { printf '%s\n' "$*" ;}
if [[ ${1:-} ]] && declare -F | cut -d' ' -f3 | fgrep -qx -- "${1:-}"
then "$@"
else main "$@"
fi
@my-pal-jason
Copy link

I believe the help should read 'Symlink a likely libjvm.so into /usr/lib.'

@candlerb
Copy link

(I agree regarding help text)

Another way to do this would be to create a text file /etc/ld.so.conf.d/jvm.conf containing the path to the directory containing libjvm.so - then run ldconfig to pick it up. This makes all .so files in that directory available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment