aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes assertions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assertions..." Watch "assertions..." New topic
Author

assertions...

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
can we set assertions programmatically? whizlabs says we can....want to know how?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Venu Chakravorty
Ranch Hand

Joined: Aug 19, 2009
Posts: 46
Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.
Swagato Bhatta
Ranch Hand

Joined: Nov 08, 2008
Posts: 72
venu chakravorty wrote:Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.


However, we still have to enable (-ea) during running for the assertion to have any effect! So, I am not still sure how programmatically you can enable the assertion (if that was the question). But definitely, assertions are disabled at runtime by default


Working on my SCWCD so I can be a J2EE consultant earning millions of dollars and showing everyone I can
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
i was talking about enabling within the program and not using the command line....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: assertions...