1

Here's a simple program that I try to run:

public class TutorialExample {

    public static void main(String[] args) {
        boolean example = true;
        assert example == true;
    }

}

I have tried to follow these steps exactly for this common issue, but am unsuccessful. I still get the resulting error that reads:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
  assert cannot be resolved to a type
  Duplicate local variable example
  Syntax error on token "==", = expected

Here is a sample image of my run configurations with the VM argument -ea included.

enter image description here

Community
  • 1
  • 1
nicholas79171
  • 1,203
  • 2
  • 15
  • 28
  • See [Exception in thread “main” java.lang.Error: Unresolved compilation problems:](http://stackoverflow.com/questions/11224201/exception-in-thread-main-java-lang-error-unresolved-compilation-problems). –  Apr 29 '16 at 01:47

1 Answers1

1

The Run Configuration only sets options for when you run your code. You have a problem with compiling the code.

Open the Preferences and go to the 'Java > Compiler' page. Check that the 'Compiler compliance level' is set the same level as the Java release you are running (but must be at least 1.4 for assert).

It is also possible to have Java settings specific to a project so also check the project 'Java Compiler' page in the Properties for the the project.

greg-449
  • 109,219
  • 232
  • 102
  • 145