By Alvin Alexander. Last updated: June 4, 2016
Enable Java assertions tip: The main thing to remember is that assertions -- new to Java 1.4 -- are not enabled by default. That's true when compiling, and also when running your program.
When compiling your code with javac
, you need to compile your source code using the "-source 1.4" option. Then, when running your program you need to specify the "-ea" of the java
or javaw
command to enable assertions.