java (使用 -source 7 或更高版本在开关中启用字符串)错误;Netbeans 7.1.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11110808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:51:20  来源:igfitidea点击:

(use -source 7 or higher to enable strings in switch) error;Netbeans 7.1.2

javanetbeans-7java-7

提问by bsm

I am using JDK 7 and Netbeans IDE 7.1.2. Going through Using string in switch

我使用的是 JDK 7 和 Netbeans IDE 7.1.2。通过走出去的开关使用字符串

Was trying to compile that sample example in my IDE but I am getting this error.

试图在我的 IDE 中编译该示例示例,但出现此错误。

switch (month.toLowerCase()) { (use -source 7 or higher to enable strings in switch) 1 error

switch (month.toLowerCase()) {(使用 -source 7 或更高版本在 switch 中启用字符串)1 个错误

Need your help.
Thanks

需要你的帮助。
谢谢

回答by Jigar Joshi

You need to set the source for your project,

您需要为您的项目设置源,

right click > properties > source > set here

右键单击> 属性> 源> 在此处设置

回答by user905686

In general on "-source 7": use JDK7

一般在“-source 7”上:使用JDK7

(For example if you are normally using JDK 6 and just want to use JDK 7 for a special project etc.)

(例如,如果您通常使用 JDK 6 而只想将 JDK 7 用于特殊项目等。)

If you still have problem to use a different JDK in Netbeans, the following steps may help.

如果在 Netbeans 中使用不同的 JDK 仍有问题,以下步骤可能会有所帮助。

First, install JDK to any directory, it does not have to be your main JDK or entered to any PATHS or so.

首先,将 JDK 安装到任何目录,它不必是您的主 JDK 或进入任何 PATHS 左右。

All these steps must be regarded

所有这些步骤都必须考虑

In Netbeans, right-click on the project -> Properties

在 Netbeans 中,右键单击项目 -> 属性

  1. -> Libraries -> Manage Platforms... -> Add Platform... and add your JDK directory
  2. -> Libraries -> Java Platform: select JDK 7
  3. -> Sources -> Source/Binary Format: select JDK 7
  1. -> 库 -> 管理平台... -> 添加平台...并添加您的 JDK 目录
  2. -> 库 -> Java 平台:选择 JDK 7
  3. -> Sources -> Source/Binary Format:选择JDK 7

回答by Vagif.Guliyev

intellij IDE handles itself, just click the red bulb and choose add JDK 7

intellij IDE 自行处理,只需单击红色灯泡并选择添加 JDK 7