• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader  RSS feed

 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to compile the following class on Linux




i compile it using:

javac -cp /usr/share/java/dom4j.jar Main.java

But when i am trying to run it, i get Exception:


$ java Main

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
at Main.main(Main.java:31)
Caused by: java.lang.ClassNotFoundException: org.dom4j.io.SAXReader
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more

Any idea on how to resolve this ?

Thanks,
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
at Main.main(Main.java:31)
Caused by: java.lang.ClassNotFoundException: org.dom4j.io.SAXReader

Ihe imported package "org.dom4j.io" do not have a class "SAXReader".
 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but according to: http://dom4j.sourceforge.net/dom4j-1.6.1/apidocs/org/dom4j/io/SAXReader.html



 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be your dom4j-1.6.1 jar is older or corrupted???
 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i actually see it in the jar:


jar tvf dom4j.jar | grep SAXReader*

1061 Mon Jan 25 09:34:34 EST 2010 org/dom4j/io/SAXReader$SAXEntityResolver.class
13170 Mon Jan 25 09:34:34 EST 2010 org/dom4j/io/SAXReader.class

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!