I am using DeferredTextImpl
Class and eclipse does not seems to complain about it but when I run my project I get run time exception .... Class not found exception for DeferredTextImpl ..
When I searched for the class file, I found it in rt.jar
which should certainly be on the class path. I also checked the build path in project properties->Java build path
and could see JRE System Library at the very bottom. when I expanded that. I could see rt.jar
. which means it is on the class path, right ?
Why am I getting this error ?
Check the version of your Xerces jar for your runtime versus you compile time classes. Make sure have a Xerces2 jar at runtime. I doubt the the class in the rt.jar is the same class your application is looking for.
There is a difference between the build path in Eclipse and the classpath when you run your code. The build path is used to compile your code. The classpath is what your application has when it runs.
The build path is configured with Project -> Properties -> Java Build Path
The class path is configured with Run -> Run Configurations -> Classpath
In your case, you should also check (as others mentioned), if the JRE tab under Run Configurations points to the same JRE as in your build path.
This class is part of a specific DOM implementation (Apache Xerces). It's not part of the public Java API, and if you do in fact find it in one JVM's runtime class library, this is no guarantee it'll be in others. If you need to explicitly work with Xerces, then you need to explicitly include the Xerces libraries on your runtime class path.
Can you try running the code by explicitly adding rt.jar with -jar option while running the code? If this works then it means that the rt.jar in eclipse is not on classpath.
Right click on project > java build path > Libraries
remove JRE and add library pointing to JDK folder which in my case is C:\Program Files\Java\jdk1.7.0_55.
But before that do the same thing with java installed JRE as well.
Windows > java > installed JRE .
Hope this will help