aspose file tools*
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
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: 2969
    
    9
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: 36499
    
  16
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: 36499
    
  16
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: 2969
    
    9
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: 36499
    
  16
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to enable assertions?
 
Similar Threads
Regarding assertion
doubt in assert...
Assertion Doubt.
K&B "assert " explanation
Assertion again.