Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Jun 14, 2013

[Solved] NoClassDefFoundError, cannot find VirtualMachine when using HotThread

Posted Jun 14, 2013
I got a NoClassDefFoundError when trying to execute HotThread.jar in Cent OS Linux using java -jar command, seems it cannot find com/sun/tools/attach/VirtualMachine which is part of tools.jar.


[root@ALFSYSTEST4-VM bin]# ./java -jar /home/samba/HotThread.jar 3223
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/VirtualMachine
        at hotthread.Main.main(Main.java:52)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
        ... 1 more


The solution is to just use the java -classpath approach and load the two libraries then execute the HotThread program:

java -classpath "/opt/jdk1.6/lib/tools.jar:/home/samba/HotThread.jar" hotthread.Main 3223



Aug 2, 2011

Alfresco Java Perm Gen Space Error

Posted Aug 2, 2011
As advised by Alfresco JVM Tuning, you can try to increase your max perm gen to 256M if you are encountering perm gen error (out of memory).
Modify or add this to your JVM Parameter / Settings:
-XX:MaxPermSize=256M

If you still observe this error after some time, it is possible that there is a memory leak somewhere that's causing this and you need to find where the leak happens.

Java 7 Has Finally Been Released

At long last, after 5 years of waiting and bureaucratism Java 7 is here! I still remember reading the Stackoverflow question: "Who is preventing the release of Java 1.7?" and was disappointed by Sun and Apache's dispute; reminds me of a failed democracy with too many people having a say, slowing the progress to a crawl.

Anyway, enough of ranting. Java 7 was released on July 28, 2011. It's also worth noting that this is the first Java release after Oracle bought Sun. This major release includes many new features including my favorite "strings in switch statements" and "try-with-resources statement". As a fan of Groovy language, I was excited by this release because it includes the much awaited JSR292 which aims to support the implementation of dynamically-typed languages promising significant performance gain. For more information about the implications of JSR292, read Baptiste Wicht's article.

For more information on the new features and enhancements, check out the release notes.  Java Development Kit (JDK) 7 is available for download here.