Enabling Assertions in Eclipse

From EQUIS Lab Wiki

Revision as of 00:55, 6 September 2005 by Graham (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Assertions are one of the most useful tools available to software engineers to help debug their code. Unfortunately, Eclipse has assertion checking turned off by default. This means that even if assertions fail, no error will be produced.

To turn assertions on, go to Window|Preferences. In the dialogue that appears, select Installed JRE's. The dialogue should look like this:

installedJREs.png

Select your JRE, and click Edit. You will come to a dialogue that looks like this:

dash-ea.png

Enter -ea under Default VM Arguments. Click Ok to save the change.

Your assertions will now be checked when you run your programs under Eclipse.