File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problem with Assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with Assertions " Watch "Problem with Assertions " New topic

Problem with Assertions

kiran vydhyam

Joined: Jul 22, 2004
Posts: 7
I have a package named A which has two source files in it one is and ,this package is in C:\ and ,I have used assertion facility in two of them.Now I want to enable assertions through package level,in turn which enables assertions in two source files.

After compiling two files separately ,I used
java -ea:A test1 ---This gives me NoClassDefFoundError A/test

Why is this??
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
After compiling, where did your class files end up? They need to be in a directory named A, which needs to be locatable through the CLASSPATH.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
kiran vydhyam

Joined: Jul 22, 2004
Posts: 7
I have a folder c:\j2sdk1.2_04\bin\javaexamples1\A
I can see the class files are in the A folder and I have specified the classpath as c:\j2sdk1.2_04\bin\javaexamples1.

But I have a doubt here,when I run this command java -ea:A test should my current directory show c:\j2sdk1.2_04\bin\javaexamples1\A or just c:\j2sdk1.2_04\bin\javaexamples1.

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

I havent used assertions much but in general,
If you are in directory <root_dir> , and you have a class A.test in directory A under <root_dir>,

You need to be in <root_dir>, and call javac from there
javac A.test

and your classpath should include <root_dir>


The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
I agree. Here's the link:
subject: Problem with Assertions
jQuery in Action, 3rd edition