Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Enable Java Assertion

Enabling Or Disabling Assertion

By default assertion is not enabled, but compiler complains if assert is used as an identifier or label. The following command will compile AssertionDemo example with assertion enabled.

javac –source 1.4 AssertionDemo.java

The resulting AssertionDemo class file will contain assertion code.

By default assertion are disabled in Java runtime environment. The argument –eanbleassertion or –ea will enables assertion, while –disableassertion or –da will disable assertions at runtime.

The following command will run AssertionDemo with assertion enabled.

Java –ea AssertionDemo

or

Java –enableassertion AssertionDemo


<< Java Assertion Tutorial    Second Form of Assertion >>
No votes yet
Share this

Post new comment