Reputation: 71
I'm using java 1.7 in intellij and it's giving me a compile error as if I'm using pre-1.7. Saying, "Incompatible type. Found 'java.lang.String'. required 'byte, char, short, or int'.
I'm rattling my brain trying to figure out why this is. Thanks
Upvotes: 6
Views: 5015
Reputation: 7676
If you add this to your pom.xml
file it will resolve the issue where the key part is the source 1.8
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Upvotes: 0
Reputation: 1
I solved my case like this:
Intellij
File -> Project Structure -> Project -> Project language level:
And in the options box I selected the option:
14 - Switch expressions
Upvotes: 0
Reputation: 1534
You need to change language level in your IDE.
Check these settings:
Also check compiler settings. Sometimes it adds extra arguments to compiler:
If you use maven plugin enable auto-import. Then the language level will be detected automatically from your pom.xml
settings.
Upvotes: 17
Reputation: 734
I think you have installed multiple JDKs on your system or you are using the default JDK that is bundled with IDE intellij. Try this link to change your JDK path to the one that is 1.7 or higher if any installed on your system or update your JDK to the latest version available
Upvotes: 0
Reputation: 28737
In your project settings most probably you use java compiler java 1.6 or prior. Change that to java 1.7
Upvotes: 1