laghdaf / jvmtop

Automatically exported from code.google.com/p/jvmtop
0 stars 0 forks source link

Doesn't work on OS X #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try and run with OS X
2. Does not work.  Says requires real JDK.

tools.jar is not packaged up as a separate jar in the OS X JDK.  You don't need 
to add it to the classpath like on Windows/Unix.  I wrote and tested the 
following fix:

if [ `uname` != 'Darwin' ] ; then
  if [ ! -f "$TOOLSJAR" ] ; then
    echo "$JAVA_HOME seems to be no JDK!" >&2
    exit 1
  fi
fi

Original issue reported on code.google.com by hughes.m...@gmail.com on 10 Sep 2013 at 11:51

GoogleCodeExporter commented 9 years ago
Thank you very much for reporting this issue and for providing a possible fix.

I currently do not have the possibility to test against OS X so I have to rely 
on the community.

If you agree, I'll include your fix into the next release of jvmtop.

Original comment by patric.r...@gmail.com on 12 Sep 2013 at 12:53

GoogleCodeExporter commented 9 years ago
Sounds good to me!  I tested and am using the updated .sh on my Mac.   Pretty 
neat tool btw.

Original comment by hughes.m...@gmail.com on 13 Sep 2013 at 2:40

GoogleCodeExporter commented 9 years ago
Additionally to this, JAVA_HOME detection in OS X is done with java_home.
See 
http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x
/ for example.

I've added similar changes to the JAVA_HOME detection in the jvm_top shell 
script and it fixes it on my OS 10.9 Mavericks Mac.

if [ -z "$JAVA_HOME" ] ; then
        if [ `uname` == 'Darwin' ] ; then
                JAVA_HOME=$(/usr/libexec/java_home)
        else
                JAVA_HOME=`readlink -f \`which java 2>/dev/null\` 2>/dev/null | \
                        sed 's/\/bin\/java//'`
        fi
fi

Original comment by mark.j.f...@gmail.com on 13 Nov 2013 at 4:45

GoogleCodeExporter commented 9 years ago
Just to add, i'm using latest homebrew version:

$ brew info jvmtop
jvmtop: stable 0.8.0
https://code.google.com/p/jvmtop/
/usr/local/Cellar/jvmtop/0.8.0 (5 files, 116K) *
  Built from source
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/jvmtop.rb

Original comment by mark.j.f...@gmail.com on 13 Nov 2013 at 4:47

GoogleCodeExporter commented 9 years ago
Mark, thanks for the update!

Two questions:

1. Do you have a clue why 
                JAVA_HOME=`readlink -f \`which java 2>/dev/null\` 2>/dev/null | \
                        sed 's/\/bin\/java//'

does not work on your OS X?
- According to comment #2, it works on at least one mac system
- even if the environment variable is named java_home, it should work 
nevertheless, because JAVA_HOME is set using the readlink autodection (see 
above) and only read afterwards

2. Regarding your suggestion: Will the path /usr/libexec/java_home work on 
every OX X system / JDK installation? If not - how should a safe OS X 
autodection of this path look like?

Original comment by patric.r...@gmail.com on 13 Nov 2013 at 7:44

GoogleCodeExporter commented 9 years ago
Maybe it's a different OS X version - for me, on Mavericks, the $JAVA_HOME 
should always be /Library/Java/Home. So by adding:

if [ `uname` = Darwin ]; then
    JAVA_HOME=/Library/Java/Home
fi

to the beginning of the shell script should always work.

Original comment by xuhdev on 30 Nov 2013 at 7:46

GoogleCodeExporter commented 9 years ago
Plus, skip the tools.jar code for OS X.

Original comment by xuhdev on 30 Nov 2013 at 7:48

GoogleCodeExporter commented 9 years ago
@xuhdev: 
Thanks for the information.
I am wondering that tools.jar does not exist for OS X. jvmtop needs some 
classes within this jar - are they part of another jar?

Original comment by patric.r...@gmail.com on 19 Aug 2014 at 8:25