In intelij maven compiling in Java SDK 1.8 but showing automatically changes to Java SDK 1.5 and shows this error
Asked
Active
Viewed 1,052 times
4
-
2Have you tried setting the source level to 1.8? – Erwin Bolwidt Dec 14 '18 at 06:07
-
1Have you specified java version in pom? – Sukhpal Singh Dec 14 '18 at 06:07
-
@SukhpalSingh yes did so it didnt work – Ayeshmantha Perera Dec 14 '18 at 08:59
-
Yes exactly @ErwinBolwidt it does the trick – Ayeshmantha Perera Dec 14 '18 at 08:59
1 Answers
5
On your pom.xml
file should have this, it specified the maven compiler to 1.8
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Or
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Dang Nguyen
- 1,209
- 1
- 17
- 29
-
Hey did so it didnt work for me I did this work around @Dang – Ayeshmantha Perera Dec 14 '18 at 06:24
-
1you should run `mvn clean install` or `mvn clean package` in command line to see if it correct, if not I think it relate to the intelij IDE. – Dang Nguyen Dec 14 '18 at 06:26
-
1Or you can visit [this question and answer here](https://stackoverflow.com/questions/9980869/force-intellij-idea-to-reread-all-maven-dependencies) to update maven in intelji – Dang Nguyen Dec 14 '18 at 06:30
-
Hi @Dang it worked but had to change the .iml file Language level to 1.8.Thanks for the support – Ayeshmantha Perera Dec 14 '18 at 06:39
-
iltelij suppose to changed the .iml file automatically after you change the `pom.xml`(the .iml file is just some config file generated by intelij and not related to your code). But I'm glad it works. – Dang Nguyen Dec 14 '18 at 06:42
-
1Cool brother thanks for the help marked the answer as correct – Ayeshmantha Perera Dec 14 '18 at 06:43