score:106

Accepted answer

to be specific:

  • go to run->run configuration
  • select java application in left nav pan.
  • right click and select new.
  • select arguments tab
  • add -ea in vm arguments.

enter image description here

score:0

in case someone uses idea, -ea is enabled by default in some idea versions, but disabled in others. to manually configure it, it is under run -> edit configuration -> vm option

score:2

you need to go to run configurations and add vm arguments as "-enableassertions" (or) "-ea"

after that when you run code with assert statement, you will see assert in action.

score:2

java introduced the assert keyword, so the way to enable source-level support is to make sure that eclipse's java compliance level is 1.4 or higher. (the chances are that the compliance level is already higher than that ...)

to cause a java application launched from eclipsed to run with assertion checking enabled, add the "-ea" argument to the vm arguments in the launcher configuration's "arguments" tab.

score:9

  1. form the menu bar, select run -> run configurations....
  2. select arguments tab.
  3. add -ea to vm arguments.
  4. click apply.
  5. click run.

score:49

if anyone wants to enable assertions by default (in contrast to enabling them for just a single run configuration), it is possible with the following steps:

  1. window (menu bar)
  2. preferences
  3. java
  4. installed jres
  5. select your jre/jdk
  6. press edit...
  7. default vm arguments
  8. add -ea

Related Query

More Query from same tag