How to fix Java language level error in Intellij?

Error:-
 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

Solution:-
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.

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

Step3:-
File > settings > Java Compiler > change to latest compiler

java compiler settings intellij


Rerun the project, hope it will work fine 🙂

Learn Selenium