How to enable the Java keyword assert in Eclipse program-wise?

Siva Kumar Reddy G picture Siva Kumar Reddy G · Jul 10, 2012 · Viewed 49.2k times · Source

How can I enable the assert keyword in Eclipse?

public class A
{
    public static void main(String ... args)
    {
        System.out.println(1);
        assert false;
        System.out.println(2);
    }
}

Answer

Priyank Doshi picture Priyank Doshi · Jul 10, 2012

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