Java Tutorials - Herong's Tutorial Examples - v8.22, by Herong Yang
JVM "-ea" and "-da" Options
This section describes '-ea' and '-da' JVM option, which are used to enable or disable assertion on application classes.
By default, "assert" statements in your are not execution to save execution time. If you are running a Java application with "assert" statements added, you can turn on the JVM assertion option to troubleshoot execution issues.
JVM ("java" command) supports a number of assertion options:
Let's re-run the sample program in the previous tutorial with the "-ea" option:
herong> java -ea AssertStatementTest.java 8 Hour specified: 8 Good morning! herong> java -ea AssertStatementTest.java 18 Hour specified: 18 Good evening! herong> java -ea AssertStatementTest.java 28 Hour specified: 28 Exception in thread "main" java.lang.AssertionError: Hour = 28. It be must be < 24. at AssertStatementTest.greeting(AssertStatementTest.java:19) at AssertStatementTest.main(AssertStatementTest.java:10) herong> java -ea AssertStatementTest.java -8 Hour specified: -8 Exception in thread "main" java.lang.AssertionError: Hour = -8. It be must be >= 0. at AssertStatementTest.greeting(AssertStatementTest.java:16) at AssertStatementTest.main(AssertStatementTest.java:10)
As you can see, both "assert" statements were executed. AssertionError messages were corrected generated.
Table of Contents
Execution Process, Entry Point, Input and Output
Primitive Data Types and Literals
Bits, Bytes, Bitwise and Shift Operations
Managing Bit Strings in Byte Arrays
Reference Data Types and Variables
StringBuffer - The String Buffer Class
System Properties and Runtime Object Methods
Generic Classes and Parameterized Types
Generic Methods and Type Inference
Lambda Expressions and Method References
Java Modules - Java Package Aggregation
Execution Threads and Multi-Threading Java Programs
ThreadGroup Class and "system" ThreadGroup Tree
Synchronization Technique and Synchronized Code Blocks
Deadlock Condition Example Programs
Garbage Collection and the gc() Method
►Assert Statements and -ea" Option