• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to enable assertions?

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



the hint is * cool *
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you never compiled or executed anything from the command line?

javac Foo.java
java Foo
 
Mike Simmons
Master Rancher
Posts: 4796
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic