compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.
However, we still have to enable (-ea) during running for the assertion to have any effect! So, I am not still sure how programmatically you can enable the assertion (if that was the question). But definitely, assertions are disabled at runtime by default