Can't define multi-catches in IntelliJ
Asked Answered
H

3

7

I work with JDK 7 in Intellij 12.0.4. When I try to create a multi-catch block it get a "multi-catches are not supported at this language level" error. I found this question but the answer doesn't work for me. This was the answer:

Click on the File menu, open Project Structure, then under "Settings" there should be "Project". Within that tab, there'll be an SDK Settings option which specifies the language version you want to use. See the JetBrains help page for more details ("Project language level").

Headstand answered 10/9, 2013 at 15:5 Comment(0)
T
14

In Project Structure -> Project Settings -> Project, set the Project language level to 7.0 - Diamonds, ARM, multi-catch etc. This should fix your problem.

Tolerance answered 10/9, 2013 at 15:22 Comment(3)
Yes, this was the answer in the provided link in my question. It still doesn't work for me :/Headstand
Are you sure you configured a correct sdk, can you take a screenshot of the Project Settings -> Project dialog, and also of the configuration of you JDK?Tolerance
Go to Project structure -> Project setting --> Modules --> Click on module come in the right side --> Source and then set the language level to 7.0 - Diamonds, ARM, Multi catch et.Paderna
E
10

In my case changing the project level from: Project Structure -> Project Settings -> Project, set the Project language level to 7.0 also didn't work cause that only set up the language level in project.ipr file but what i needed was to set it up in the project.iml file. If you have similar problem you could always set things manually or you can try alt+enter on the code where you use the multi catch block and choose "Set language level to 7.0 - Diamonds, ARM, multi-catch etc."

Emelia answered 5/11, 2013 at 12:58 Comment(0)
W
1

Hope you have set the compiler version correct. If yes the try to

File | Invalidate Caches

To add a JDK to project, press Ctrl+Alt+Shift+S, under Platform Settings click JDKs and specify JDK path. After that, you can click Project and specify which of JDK you have configured is used in the current projects. Remember that JDKs are configured at IDE level, so when you create another project, you won't need to add the same JDK again.

Waligore answered 10/9, 2013 at 15:7 Comment(1)
Where should I set the compiler version (I think I set it up correctly but want to make sure). The invalidate caches didn't workHeadstand

© 2022 - 2024 — McMap. All rights reserved.