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

ClassNotFoundException on MacOS/Java 8 #12

Closed
fs111 opened this issue Feb 7, 2017 · 6 comments
Closed

ClassNotFoundException on MacOS/Java 8 #12

fs111 opened this issue Feb 7, 2017 · 6 comments

Comments

@fs111
Copy link

fs111 commented Feb 7, 2017

When I try to run a build of HEAD, I get the following:

$ bin/jvm-mon
Exception in thread "main" java.lang.NoClassDefFoundError: sun/jvmstat/monitor/MonitorException
	at com.jvmtop.view.VMOverviewView.scanForNewVMs(VMOverviewView.java:157)
	at JvmMon.update(JvmMon.java:38)
	at JvmMon.main(JvmMon.java:22)
Caused by: java.lang.ClassNotFoundException: sun.jvmstat.monitor.MonitorException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 3 more
$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
$ uname -a
Darwin somehost.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan  9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64
@ajermakovics
Copy link
Owner

There could be a couple of problems:

  • JAVA_HOME env var is not set
  • JAVA_HOME does not point to a JDK

jvm-mon needs tools.jar to be on the classpath so a quick check is to run stat $JAVA_HOME/lib/tools.jar

@abstractj
Copy link

abstractj commented Feb 8, 2017

@ajermakovics I got the same issue and this is how it looks like the content of my JAVA_HOME

~/t/j/bin ❯❯❯ ls $JAVA_HOME/lib
amd64           visualvm        ct.sym  ir.idl         jconsole.jar  orb.idl       sa-jdi.jar
missioncontrol  ant-javafx.jar  dt.jar  javafx-mx.jar  jexec         packager.jar  tools.jar

Version:

~/t/j/bin ❯❯❯ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

@ajermakovics
Copy link
Owner

MonitorException comes from tools.jar so somehow it is not getting added to the classpath

What if you run it directly:

cd jvm-mon-0.1/
java -cp $JAVA_HOME/lib/tools.jar:lib/jvm-mon-0.1.jar JvmMon

@ajermakovics
Copy link
Owner

The new version (0.2) will print a warning if tools.jar is not found

@fs111
Copy link
Author

fs111 commented Feb 8, 2017

The fix to get a valid JAVA_HOME on OS-X is this:

$ export JAVA_HOME=$(/usr/libexec/java_home)

It works now. Thanks!

@fs111 fs111 closed this as completed Feb 8, 2017
@abstractj
Copy link

@ajermakovics worked like a charm, thank you!

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

3 participants