Studying on how to use class imports and came along with a NoClassDefFoundError I wrote two classes as below, with one using the other
I put the files in a directory called test when I put the B.class file in the test directory, A.java won't compile but when I put the B.class file in a subdirectory also called test, A compiles but when I try to run A, it just shows me the NoClassDefFoundError message If I take away the package test; line in A.java, it also fails compile
what should I do? change classpath? change directories? change code? thanks in advance.
Just take my heart when you go<br />I don't have a need for it anymore<br /> <br />5/9 SCJP 1.4 passed<br />8/15 SCBCD 1.3 passed<br />SCWCD (in progress)
Joined: May 18, 2004
What happens when you take out the import line in A?
Joined: Sep 13, 2002
Take out the "import test.*;" line - you don't need to explicitly import classes that belong to the same package.
Then you need to make sure that package structure matches your directory structure and that the root directory (e.g. in your case, the directory one level above your "test" directory) is included in your classpath. So, if you have C:\projects\test\A.class, make sure C:\projects is included in your classpath.
Finally, when you launch your app, make sure to specify the fully-qualified name, e.g. "java -cp <add your classpath here> test.A"
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"