简体   繁体   中英

Eclipse: false error with jdk7

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构建路径

Java编译器

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.

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 (ie the one from your installed / configured JDK) is used to generate the ".class" files.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM