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

梦想的初衷 提交于 2019-12-08 18:14:17

问题


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

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

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

Need your help.
Thanks


回答1:


You need to set the source for your project,

right click > properties > source > set here




回答2:


In general on "-source 7": use JDK7

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

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

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

All these steps must be regarded

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

  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



回答3:


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



来源:https://stackoverflow.com/questions/11110808/use-source-7-or-higher-to-enable-strings-in-switch-errornetbeans-7-1-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!