Avi
Avi

Reputation: 21866

Can't define multi-catches in IntelliJ

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").

Upvotes: 7

Views: 5976

Answers (3)

Krasimir Dimitrov
Krasimir Dimitrov

Reputation: 160

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."

Upvotes: 10

Juned Ahsan
Juned Ahsan

Reputation: 68715

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.

Upvotes: 1

Marcelo
Marcelo

Reputation: 11308

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

Upvotes: 14

Related Questions