This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes How to enable assertions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to enable assertions?" Watch "How to enable assertions?" New topic
Author

How to enable assertions?

Vishnu Sharma
Ranch Hand

Joined: Feb 03, 2010
Posts: 55
I am using following command for enabling assertion in my code, which i have saved using Asserttest.java file.

java -enableassertions Asserttest.java

But i am getting the following compilation error:
Exception in thread "main" java.lang.NoClassDefFoundError: Asserttest/java

Please tell me the right command. Thanks in advance.

Regards,
Vishnu
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3011
    
  10
I'll give you a hint: your problem really has nothing to do with assertions.

How would you run this program without enabling assertions?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Mike Simmons wrote:How would you run this program without enabling assertions?


the hint is * cool *
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38441
    
  23
Another hint: Look at the Java™ Tutorials and use ctrl-F "Run the Program" which takse you to the end of the page, where you see exactly which instruction you should use after "java". Note you miss out the extension.
Vishnu Sharma
Ranch Hand

Joined: Feb 03, 2010
Posts: 55
Mike Simmons wrote:I'll give you a hint: your problem really has nothing to do with assertions.

How would you run this program without enabling assertions?


Actually i just want to check the functionality of assert keyword. I read that by default assertions are disabled. we need to enable them and that command was given. But it is not working for my code. Can you now give me some solution??
Vishnu Sharma
Ranch Hand

Joined: Feb 03, 2010
Posts: 55
Campbell Ritchie wrote:Another hint: Look at the Java™ Tutorials and use ctrl-F "Run the Program" which takse you to the end of the page, where you see exactly which instruction you should use after "java". Note you miss out the extension.


In Run The Program, no assertions related stuff is given. my code is saved using Asserttest.java. Can you give me the exact command for it??
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

how do you compile a java file ? and how do you run a class file ? from command prompt
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38441
    
  23
Have you never compiled or executed anything from the command line?

javac Foo.java
java Foo
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3011
    
  10
Vishnu Sharma wrote:In Run The Program, no assertions related stuff is given.

As I said, your problem really has nothing to do with assertions. The issue you're having is more fundamental, and you would have the same issue with a "Hello World" program.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38441
    
  23
Mike Simmons wrote: . . . you would have the same issue with a "Hello World" program.
Like what I showed you. Have you got anything to run at all, with or without assertions?
 
wood burning stoves
 
subject: How to enable assertions?