Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 436
Avi Avatar asked Sep 10 '13 15:09

Avi


3 Answers

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

like image 64
Marcelo Avatar answered Nov 02 '22 10:11

Marcelo


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

like image 44
Krasimir Dimitrov Avatar answered Nov 02 '22 11:11

Krasimir Dimitrov


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.

like image 37
Juned Ahsan Avatar answered Nov 02 '22 09:11

Juned Ahsan