3

I've been having a problem with eclipse that's been stressing me a lot. Whenever I start a new Java porject, everything goes smoothly and perfect, until I "clean" the project (Project -> Clean...) and everything goes to @#~%&...
I keep getting:

  • XYZ cannot be resolved to a type
  • Multi-catch parameters are not allowed for source level below 1.7
  • <> operator is not allowed for source level below 1.7

That's very nice, only that I am importing all required classes and I do have 1.7 since the begginig. It's the only version I've installed. I've already tried this and other similar responses for the last few days with no avail.
A solution was to create a new project, copy and paste all packages/clases, which worked for a while, but I added UMLet to the project and again... Removing UMLet plugin did nothing for me.

BTW, even with the "errors", my project runs without any problem, therefore I know they're not real. I could keep working, but then, I can't see when a real error arises... Does anyone got a final solution to get rid of this false errors?

EDIT: I forgot to mention that I'm working with Kepler.

EDIT 2:

Here are screen captures with the requested information.

Java Build Path

Java Compiler

Community
  • 1
  • 1
ZamPrano
  • 63
  • 1
  • 1
  • 8
  • Have you checked the source compliance level of your project or of eclipse in general? Preferences -> Java -> Compiler – tobias_k Feb 14 '14 at 12:22
  • Yep. Everything's on 1.7 – ZamPrano Feb 14 '14 at 12:42
  • 1
    In the *project's* Properties, **Java Build Path** section, **Libraries** tab, what `JRE System Library` is listed there? In the**Java Compiler** section, what is the **JDK Compliance** set to? – E-Riz Feb 14 '14 at 13:54
  • Just edited my question, adding the screen captures showing the requested information. – ZamPrano Feb 17 '14 at 08:46

3 Answers3

5

You can solve this by setting up correct JRE environment in Eclipse as below.

  1. Go to Project => Properties => Java Build Path
  2. Click on Libraries
  3. Select JRE System Library
  4. Click on Edit button at right hand side
  5. Set Execution Environment to Jave SE-1.7(jre7)
  6. Clean project or refresh project.
Igor Yavych
  • 4,166
  • 3
  • 21
  • 42
Yogesh Varal
  • 121
  • 1
  • 3
  • 12
2

A solution was to create a new project, copy and paste all packages/clases, which worked for a while, but I added UMLet to the project and again...

One possibility is that the UMLet plugin is the cause of your problems. Try a clean Eclipse install without UMLet. (The fact that uninstalling the UMLet plugin didn't fix the problem is in no way conclusive.)

Note that UMLet will run as a stand-alone tool.

BTW, even with the "errors", my project runs without any problem, therefore I know they're not real.

The likely explanation for that is that the compilation errors come from the incremental Java compiler that is built into Eclipse. A different compiler (i.e. the one from your installed / configured JDK) is used to generate the ".class" files.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

Multi-catch parameters are not allowed for source level below 1.7

not a solution, to this issue, but if you want to have two exceptions you can code it like this:

try {
    // code here
} catch {
    // code here
} catch {
    // code here
}

it worked for me, instead of having catch (exception1 | exception2 e)

Cœur
  • 37,241
  • 25
  • 195
  • 267