jvmtop
jvmtop copied to clipboard
JAVA_HOME detection fails
jvmtop.sh does not allow symlinking, JAVA_HOME detection does not work, even for Oracle JDK if the path does contain "bin" multiple times.
Updated jvmtoph.sh
#!/bin/sh
# jvmtop - java monitoring for the command-line
# launch script
#
# author: Markus Kolb
#
# set -x
# determine installation directory
realpath=$(readlink -f "$0")
DIR=$(dirname "${realpath}")
# Make sure, JAVA_HOME and the java executable are available
if [ ! -z "$JAVA_HOME" ] ; then
java="${JAVA_HOME}/java"
else
# try the default installed JDK (i.e.: find javac)
javac=$(readlink -f $(which javac 2>/dev/null) 2>/dev/null)
bin_dir=$(dirname "${javac}")
JAVA_HOME=$(dirname "${bin_dir}")
java="${JAVA_HOME}/bin/java"
fi
TOOLSJAR="${JAVA_HOME}/lib/tools.jar"
if [ ! -f "$TOOLSJAR" ] ; then
# some dists like CentOS use this directory layout
TOOLSJAR="${JAVA_HOME}/../lib/tools.jar"
if [ ! -f "$TOOLSJAR" ] ; then
echo "No JDK installed or JAVA_HOME='$JAVA_HOME' seems to be no JDK!" >&2
exit 1
fi
fi
"${java}" $JAVA_OPTS -cp "$DIR/jvmtop.jar:$TOOLSJAR" \
com.jvmtop.JvmTop "$@"
exit $?
This should also fix #79
(The updated comment just contains fixed github syntax hilighting) (Added quoting as suggestet by muxator)
Hi @HonoluluHenk, for what concerns
jvmtop.sh does not allow symlinking
Do you think that it can be fixed via pull request #95?
My only concern is about the project: there is not much activity lately.
Hi @muxator Unfortunately, #95 does not solve the problem. The other PR is not related to this problem at all :(
Oh, I see. In fact the symlink support is literally present in your version, so no need for #95.
Should we make a pull request for your version?
Maybe java=${JAVA_HOME}/java could be quoted (java="${JAVA_HOME}"/java).
Should we make a pull request for your version?
Yes, be my guest :) (I added your quoting enhancement in the original post)