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:
Enable assertions in all classes in the unnamed package:
Enable assertions in all classes in a package subtree:
Enable assertions in a particular class:
Disable assertions in all classes in a package subtree:
Disable assertions in a particular class:
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 MyApp
java -ea:... MyApp
java -ea:com.mycompany... MyApp
java -ea:com.mycompany.MyCompany MyApp
java -da:com.mycompany... MyApp
java -da:com.mycompany.MyClass MyApp
java -ea:com.mycompany... -da:com.mycompany.MyClass MyApp
Post a comment