Get rid of stupid “NoClassDefFoundError” in Ubuntu

We use a small Java application to monitor SMS services in our company. This client application connect to the server via internet, means I can monitor the services from anywhere. It was working fine both on Windows as well Ubuntu. Three days earlier when I was cleaning up some applications after Ubuntu File System got full, I mistakenly removed JRE(Java Runtime Environment) too. Though I re-installed it later but my service monitoring application won’t run and keep printing this error in terminal:

Exception in thread “main” java.lang.NoClassDefFoundError: uk.co.planetbeyond.servicemonitor.gui.ClientMain
at java.lang.Class.initializeClass(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: javax.swing.RowSorter not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/sajid/sm/sm.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.Class.initializeClass(libgcj.so.90)

I googled it to get some solution but everyone had its own answer for this error. Browsing through this thread over Ubuntu forums I found this solution and it worked for me. All I have to do is to run this command in a terminal:
sudo update-java-alternatives -s java-6-sun
According to the author this command sets the JRE6 to run by default. That No Class Def Found error was probably due to invalid path to the appropriate JRE installation. Give it a try if your are facing this error.

No related posts.


No comments yet.

Leave a comment

(required)

(required)