The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.lang  [58 examples] > Assertions  [3 examples]

e104. Enabling Assertions from the Command Line

The command line options -ea and -da allow you to enable and disable assertion in a package subtree or in a class. Here are several examples of the switches. Enable assertions in all non-system classes:
    java -ea MyApp

Enable assertions in all classes in the unnamed package:
    java -ea:... MyApp

Enable assertions in all classes in a package subtree:
    java -ea:com.mycompany... MyApp

Enable assertions in a particular class:
    java -ea:com.mycompany.MyCompany MyApp

Disable assertions in all classes in a package subtree:
    java -da:com.mycompany... MyApp

Disable assertions in a particular class:
    java -da:com.mycompany.MyClass MyApp

Multiple assertion switches on the command line are processed from left to right. Enable assertions in all classes in a package subtree except for one class:
    java -ea:com.mycompany... -da:com.mycompany.MyClass MyApp

 Related Examples
e103. Compiling a Program with Assertions
e105. Handling an Assertion Error

See also: Arrays    Classes    Commands    Numbers    Objects    Strings    System Properties    Threads   


© 2002 Addison-Wesley.