Eclipse: enable claims

I am running Eclipse Galileo. How to include statements in Eclipse?

As suggested by other sites, I tried to add arguments: -ea . I also tried changing the compiler compliance level to 1.4 . None of these suggestions worked.

+86
java compiler-construction eclipse assertions
Apr 01 2018-11-11T00:
source share
5 answers
  • Go to the Run menu and then to the Run Configurations menu item.

enter image description here

  1. In the left pane, navigate to Java Application , and then go to Assertions .

  2. In the right pane, select the Arguments tab.

  3. In the VM arguments field, enter -ea to enable the statements.

enter image description here

  1. Click the Apply button, and then Run .


To globally set it as the default value for everything:

  • Go to the Window menu (if you are on Windows) or go to the Eclipse menu (if you are on a Mac). For Linux, it might be something similar.

  • Go to Preferences .

  • Select Java and then Installed JREs in the left pane.

  • Select JRE and click the Edit... button in the right pane.

  • In the Default VM arguments field, add -ea .

+145
Apr 01 2018-11-11T00:
source share

If you want to solve this problem globally for all JUnit tests, go to Preferences > Java > JUnit and at the top of the screen check the box " Add" ea "to the arguments of the virtual machine when creating a new JUnit launch configuration " Now Eclipse will not beat you for every The new test you want to run. For existing tests, you must remove their run configurations in Run Configuration > JUnit .

+35
Nov 19 '12 at 16:07
source share

To do this globally for all Java launches, edit the Properties Installed JRE.

For example: Windows → Settings → highlight the standard JRE → click Change ... → In the default VM argument input field, enter -ea → click the finish button.

It worked on the Eclipse Kepler SR2.

+10
May 12 '14 at
source share

In maven projects, you can run the main method using the auto-magic classpath method with:

 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 a terminal window with bash for more convenient use.

+4
Feb 05 '13 at 12:07 on
source share

Do you want to include claims for the application that you are using from Eclipse? I usually just add -ea to the command line options in the Run As profile.

+3
Apr 01 '11 at 4:30
source share



All Articles