Windows and CLASSPATH problems

I think I can get myself up to speed on JUnit itself OK, but I'm having some trouble getting off the ground...

I am running Windows XP home and working from within a Cygwin environment. I can't seem to get Java to find the JUnit classes in the junit-4.5.jar file that came with my distribution.

I think I understand the concept of a jar file well enough, and I think I understand about setting the CLASSPATH so that any jar file you are intending to use must be named within it.

To test that (whether I really know what I am doing regarding jar files and CLASSPATH) I created my own jar file (which is a class with a simple wrapper around System.out.println() ) and put the jar in my java/lib directory. I then wrote a simple program that uses that class and it works fine.

I then put the junit-4.5.jar file next to my own jar file, set the CLASSPATH similarly, and tried to simply import a JUnit class from it but I can't seem to. I am at a loss for why the JUnit classes aren't being found?

Below is actual shell output demonstrating what I described above:

ej@mako ~/java
$ cd lib

ej@mako ~/java/lib
$ ls
ej.jar junit-4.5.jar
$ jar tvf junit-4.5.jar | grep Core
4099 Sat Jun 30 14:03:50 MDT 2007 org/hamcrest/CoreMatchers.class
5365 Tue Aug 19 15:12:08 MDT 2008 org/junit/runner/JUnitCore.class
$ jar tvf ej.jar
0 Thu Feb 26 13:14:00 MST 2009 META-INF/
44 Thu Feb 26 13:14:00 MST 2009 META-INF/MANIFEST.MF
0 Thu Feb 26 13:09:48 MST 2009 net/
0 Thu Feb 26 13:09:56 MST 2009 net/earthlink/
0 Thu Feb 26 13:10:34 MST 2009 net/earthlink/ejohnso9/
654 Thu Feb 26 13:10:34 MST 2009 net/earthlink/ejohnso9/ShortPrint.class
680 Thu Feb 26 13:08:06 MST 2009 net/earthlink/ejohnso9/ShortPrint.java
$ cd ../junit_try/

ej@mako ~/java/junit_try
$ ls
junitTry.class junitTry.java
$ cat junitTry.java
//import static net.earthlink.ejohnso9.ShortPrint.*;

import net.earthlink.ejohnso9.ShortPrint;
//import org.junit.runner.JUnitCore;

public class junitTry
{
public static void main(String[] args)
{
ShortPrint.println("ShortPrint.println() is working!");
}
}

ej@mako ~/java/junit_try
$ rm junitTry.class
$ javac junitTry.java
$ java junitTry
ShortPrint.println() is working!
$ vi junitTry.java
# uncomment 3rd import line: //import org.junit.runner.JUnitCore;
$ javac junitTry.java
junitTry.java:4: package org.junit.runner does not exist
import org.junit.runner.JUnitCore;
^
1 error

I don't get it. Why does it not it exist? I can see it in the junit-4.5.jar file that is sitting right next to my own jar file. Both jar files are named in a similar manner in my CLASSPATH environment variable?

$ echo $CLASSPATH
.;C:\Program Files\Java\jre1.6.0_07\lib\ext\QTJava.zip;C:\Program Files\Java\jre
1.6.0_07\lib\ext\;C:\Documents and Settings\ej\Desktop\src\java\lib\junit-4.5.ja
r;C:\Documents and Settings\ej\Desktop\src\java\lib\;C:\TIJ4-code\;C:\Documents
and Settings\ej\Desktop\src\java\lib\ej.jar

Ummm, word wrapping sort of gets messed up here. Here's the same thing as above, one path per line:
.
C:\Program Files\Java\jre1.6.0_07\lib\ext\QTJava.zip
C:\Program Files\Java\jre1.6.0_07\lib\ext\
C:\Documents and Settings\ej\Desktop\src\java\lib\junit-4.5.jar
C:\Documents and Settings\ej\Desktop\src\java\lib\
C:\TIJ4-code\
C:\Documents and Settings\ej\Desktop\src\java\lib\ej.jar

Help? Anybody see what's wrong?

junit and windows classpath

Hi,
I see that in your classpath you specify a junit-4.5.jar location on your desktop. However, when you downloaded Junit, where did you extract the entire package (e.g. D:\junit4.5)?