Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAVA_HOME detection fails #103

Open
HonoluluHenk opened this issue Jun 28, 2017 · 5 comments
Open

JAVA_HOME detection fails #103

HonoluluHenk opened this issue Jun 28, 2017 · 5 comments

Comments

@HonoluluHenk
Copy link

jvmtop.sh does not allow symlinking,
JAVA_HOME detection does not work, even for Oracle JDK if the path does contain "bin" multiple times.

@HonoluluHenk
Copy link
Author

HonoluluHenk commented Jun 28, 2017

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)

@muxator
Copy link

muxator commented Aug 28, 2017

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.

@HonoluluHenk
Copy link
Author

Hi @muxator
Unfortunately, #95 does not solve the problem. The other PR is not related to this problem at all :(

@muxator
Copy link

muxator commented Aug 28, 2017

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).

@HonoluluHenk
Copy link
Author

Should we make a pull request for your version?

Yes, be my guest :)
(I added your quoting enhancement in the original post)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants