简体   繁体   English

无法在IntelliJ中定义多次捕获

[英]Can't define multi-catches in IntelliJ

I work with JDK 7 in Intellij 12.0.4. 我在Intellij 12.0.4中使用JDK 7。 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. 在该选项卡中,将有一个SDK设置选项,指定您要使用的语言版本。 See the JetBrains help page for more details ("Project language level"). 有关详细信息,请参阅JetBrains帮助页面(“项目语言级别”)。

在项目结构 - >项目设置 - >项目中,将项目语言级别设置为7.0 - 钻石,ARM,多捕获等。这应该可以解决您的问题。

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. 在我的情况下,从项目结构 - >项目设置 - >项目更改项目级别,将项目语言级别设置为7.0也不起作用,因为只在project.ipr文件中设置语言级别但我需要的是在project.iml文件中设置它。 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." 如果您有类似的问题,您可以随时手动设置或者您可以在使用多捕获块的代码上尝试alt + enter并选择“将语言级别设置为7.0 - 钻石,ARM,多捕获等”。

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. 要将JDK添加到项目,请按Ctrl + Alt + Shift + S,在“平台设置”下单击“JDK”并指定JDK路径。 After that, you can click Project and specify which of JDK you have configured is used in the current projects. 之后,您可以单击“项目”并指定在当前项目中使用的已配置的JDK。 Remember that JDKs are configured at IDE level, so when you create another project, you won't need to add the same JDK again. 请记住,JDK是在IDE级别配置的,因此在创建另一个项目时,您不需要再次添加相同的JDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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