• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to enable assertions?

 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Simmons wrote:How would you run this program without enabling assertions?


the hint is * cool *
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you compile a java file ? and how do you run a class file ? from command prompt
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you never compiled or executed anything from the command line?

javac Foo.java
java Foo
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic