I have two jar files, A.jar and B.jar. A contains my main function and it relies on classes defined in B.

I put A and B in the same folder, which is in the Windows PATH, and try and run my main in A...

```
java -jar A.jar -dosomething

```

This gives me a `java.lang.NoClassDefFound` error on a method of B that I call in the code underneath -dosomething. Interestingly it has found A.jar and called the main method, but it can't find B.jar, even though it is in the same folder as A.jar.

So I read around (again) about CLASSPATHs and the JAVA\_HOME variable and I made sure that my JAVA\_HOME is pointing to the right place. [This document](http://docs.oracle.com/javase/6/docs/technotes/guides/extensions/spec.html) describes how I should be able to put my extension jar file(s), in my case B, into the /lib/ext folder, so I tred that, but I get the same `java.lang.NoClassDefFound` error.

I am using Java jdk1.5.0\_10, so for good measure I also placed B.jar in the jre/lib/ext folder underneath there.

So now I have it in three places, the local folder on the PATH, JAVA\_HOME/lib/ext and JAVA\_HOME/jre/lib/ext and I still get the same error.

Should using lib/ext work? Where on earth have I got to put my B.jar file for this to work properly?