How to enable assert keyword in Eclipse?
assert
public class A { public static void main(String ... args) { System.out.println(1); assert false; System.out.println(2); } }
Specifically:
Run->run configuration
java application
select New
Arguments
-ea
If someone wants to enable the default statements (as opposed to including them for only one launch configuration), you can follow these steps:
Run
Run Configurations...
VM arguments
Apply
You need to go to run the configurations and add the vm arguments as "-enableassertions" (or) "-ea"
After that, when you run the code using the assert statement, you will see assert in action.
Java introduced the assert keyword, so the way to enable support at the source level is to make sure that the Java Eclipse compliance level is 1.4 or higher. (Probably the level of compliance is already higher ...)
To force the Java application launched from Eclipsed to run with the validation statement enabled, add the -ea argument to the virtual machine arguments on the Arguments tab in the launchpad.