How to fix Java language level error in Intellij?

 java: strings in switch are not supported in -source 1.5
  (use -source 7 or higher to enable strings in switch)

java string source error

Why this error, as we are trying to access feature of java(in our case switch statements) using java 1.5 which is actually supported in higher version of java (7 in our case).

IDE used is Intellij.

File > Project Structure >Project > Project language level
Change this to 1.7 or higher
java language level error in selenium
File > Project Structure > Modules > Select the module > language level
intellij change language level

File > settings > Java Compiler > change to latest compiler

java compiler settings intellij

Rerun the project, hope it will work fine 🙂

Learn Selenium