File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes java.lang.NoClassDefFoundError: junit.framework.Test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.NoClassDefFoundError: junit.framework.Test" Watch "java.lang.NoClassDefFoundError: junit.framework.Test" New topic

java.lang.NoClassDefFoundError: junit.framework.Test

Deepti Bhatia

Joined: Oct 19, 2006
Posts: 25

I am getting the below error when the junit test class is run. The junit jar has been configured on the classpath.

java.lang.NoClassDefFoundError: junit.framework.Test
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(
at java.lang.J9VMInternals.initialize(
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadTestLoaderClass(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

Please tell the details. How you run the program, from command line/build script ? and which command(s) used ? Where is your source/compiled package hierarchy located ? Show us the classpath entry ?

[How to ask questions] [Twitter]
Deepti Bhatia

Joined: Oct 19, 2006
Posts: 25
Program run with eclipse Run -> Junit.

Source - >CSRT-presentation/src/main/java
- >CSRT-presentation/src/test/java
Classes - > CSRT-presentation/target/classes

Classpath entry - > <classpathentry kind="lib" path="C:/Documents and Settings/user/Desktop/LIB/junit-3.8.1.jar"/>
Alan Hampson
Ranch Hand

Joined: Apr 10, 2009
Posts: 31
Check your Project Properties->Java Build Path->Libraries (tab). JUnit should be there although this usually will show up in the build.

Check you Project's Run Configurations->JUnit->Classpath (tab). JUnit should be under User Entries for your project.

BTW, Eclipse has it's own junit.jar (under eclipse/plugins), so you may want to use that for consistency.

Hope this helps,
Deepti Bhatia

Joined: Oct 19, 2006
Posts: 25
Added junit jar in User Entries as suggested. It is not able to load the test class now.

Class not found com.pck.TestClass
java.lang.ClassNotFoundException: com.pck.TestClass
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
I agree. Here's the link:
subject: java.lang.NoClassDefFoundError: junit.framework.Test
jQuery in Action, 3rd edition