• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Switch not accepting String as condition, even on Java 1.8

 
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I’m having a bit of an issue, and I’m wondering if it might be something simple ... I’m using IntelliJ and Java 1.8 (I verified this under settings / platform settings / SDK and saw java 1.8 everywhere), yet this code throws an error right at line 9 below ... it red underlines the variable name and reports this error:

Error:(257, 16) java: strings in switch are not supported in -source 1.6
(use -source 7 or higher to enable strings in switch)



Here is the code:



Any idea’s as to why I’m being told my Java is too old when it isn’t? And before someone mentions the “break;" in each case, know that I tried this with and without the breaks and I get the same results.

Thank you,

Mike Sims
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael D Sims wrote:I’m using IntelliJ and Java 1.8



And yet, it's using 1.6 (Java 6).

Error:(257, 16) java: strings in switch are not supported in -source 1.6



I have moved this to the IDEs forum where someone may be able to help you with your settings.
 
Michael D Sims
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:And yet, it's using 1.6 (Java 6).


I think what may have happened is I had 1.6 installed when I installed IntelliJ, but then upgraded to 1.8 .. but the odd thing is, when I go to settings (Option + ;) then look at the Platform settings under SDK, all of my Classpath’s point to /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home... with different subfolders under that parent folder. That same path appears in all tabs under SDK.

Maybe I’ll try removing then re-installing IntelliJ and see if it doesn’t “properly” pick up 1.8.

Bear Bibeault wrote:I have moved this to the IDEs forum where someone may be able to help you with your settings.


Much appreciated :-)

Mike
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your project settings in IntelliJ: File / Project Structure / Project, make sure that Project SDK is set to a version 1.8 JDK (if it isn't in the list click the "New" button and point it to your JDK 8 installation directory), and make sure that Project language level is set to 8.0.
 
Michael D Sims
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Check your project settings in IntelliJ: File / Project Structure / Project, make sure that Project SDK is set to a version 1.8 JDK (if it isn't in the list click the "New" button and point it to your JDK 8 installation directory), and make sure that Project language level is set to 8.0.



It was the Project Language Level - it was set to 6.0 ... thank you very much.

:-)

Mike Sims
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also check the Project Structure->"Module Name"->Sources tab.

There is a language level drop down that i had to explicitly set to 8 (lambdas and other fun!).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic