Accepted answer
  1. go to the menu run, and then to the menu item run configurations.

enter image description here

  1. in the left panel, go to java application, and then go to assertions.

  2. in the right panel, choose the tab arguments.

  3. under the field for vm arguments, type -ea to enable assertions.

enter image description here

  1. click on the apply and then run button.

to globally set it as the default for everything:

  1. go to menu window (if you are on windows), or go to menu eclipse (if you are on mac). for linux it might be something similar.

  2. go to preferences.

  3. choose java, and then installed jres from the left panel.

  4. select your jre, and then click the edit... button in the right panel.

  5. in the default vm arguments field, add -ea.


you want to enable assertions for an application you're running from eclipse? i usually just add -ea to the command line parameters in the "run as" profile.


on maven projects you can run main method with auto-magic classpath by:

bash> export maven_opts="-ea" && mvn exec:java -dexec.mainclass="com.your.class.with.main"
cmd> set maven_opts="-ea" && mvn exec:java -dexec.mainclass="com.your.class.with.main"

in linux/eclipse you can add terminal window with bash for more convenient use.


to do this globally for all java runs, edit the installed jres properties.

for example: windows -> preferences -> highlight the default jre -> click edit... -> in the default vm arguments input box, enter -ea -> click the finish button.

this worked on eclipse kepler sr2.


if you want to solve this issue globally for all junit tests then go to preferences > java > junit and at the top click the checkbox for "add 'ea' to vm arguments when creating new junit launch configuration" now eclipse won't bug you for every new test you want to run. for existing tests you have to remove their's run configurations in run configuration > junit.

Related Query

More Query from same tag