Note that there are some explanatory texts on larger screens.

plurals
  1. POJUnit sample program compiling but giving runtime error
    primarykey
    data
    text
    <p>I am starting off with JUnit in Ubuntu and tried to execute the sample program given <a href="http://www.tutorialspoint.com/junit/junit_environment_setup.htm" rel="nofollow">here</a>. I have also followed instructions as given in the same link. The code compiles succesfully but gives runtime error as follows:</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/JUnitCore at TestRunner.main(TestRunner.java:7) Caused by: java.lang.ClassNotFoundException: org.junit.runner.JUnitCore at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 1 more </code></pre> <p>So far this is what I have got. This error occurs if the <code>$CLASSPATH</code> variable isn't set to the location of the classes required by it.</p> <pre><code>&gt; echo $CLASSPATH /home/webyog/workspace/JUNIT/junit-4.11.jar:. </code></pre> <p>My java files and class files are in <code>/home/webyog/JUNIT_WORKSPACE/</code> and all the libraries and the JUnit jar file is in <code>/home/webyog/workspace/JUNIT/</code>. I executed these in order:</p> <pre><code>javac TestJunit.java TestRunner.java -classpath /home/webyog/workspace/JUNIT/junit-4.11 </code></pre> <p>(This generated 2 files <code>TestRunner.class</code> and <code>TestJunit.class</code>)</p> <pre><code>java TestRunner -classpath $CLASSPATH </code></pre> <p>(This gives the error)</p> <p>What I am I missing? Please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload