5
votes

I'm running a Java Maven project on IntelliJ, and I make sure that this project will be compiled by Java 1.8.

I set JRE to version 8 in Run/Debug Configuration enter image description here

and also in Project Structure: enter image description here My pom.xml file also includes java version 8 by the following:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

and

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>

I also set Java compiler option to version 1.8.enter image description here

When I run the project, I get an error:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project feed_matcher: Fatal error compiling: invalid target release: 1.8 -> [Help 1]

Do you know how to resolve this issue?

P.S I followed this link: IDEA: javac: source release 1.7 requires target release 1.7 and I still couldn't resolve the problem.

3
Is it a Maven project? Then make sure that in the pom.xml there isn't a setting that says it should use Java 8.Jesper
IntelliJ still tries to compile Java 8 code (and the Java 7 compiler complains). Double check the compiler settings too.Thorbjørn Ravn Andersen
@ThorbjørnRavnAndersen, how can I check it in IntelliJ? I already showed project structureCrazySynthax
If it is a maven project, you may have done the compiler configuration incorrectly in the pom.xml. Can you run "mvn clean install" from the command line having JAVA_HOME Pointing to your Java 7 installation?Thorbjørn Ravn Andersen

3 Answers

4
votes

I assume you want to have it in version 8, despite so many comments telling you to set to 7.

You probably missed the setting for the maven runner, this is under Preferences -> Build, Exection, Deployment > Build Tools > Maven > Runner, see attached image. You need to set that to Java 8 as well. config screenshot

3
votes

Look in Build Execution, Deployment > Compiler > Java Compiler

Then look for per module bytecode version

1
votes
  • Make sure JAVA_HOME is set to JDK7 or JRE7. This is explained in the following link

  • Make sure that you open a new shell an run intellij

  • If this doesnt work, look at at the idea.bat file which is used to run intellij - make sure it uses jdk7/jre7
  • Make sure the JDKs are defined properly in your project. Look at this link for more information.
  • Make sure that the source is defined as 1.7 at maven

The above 4 steps always helped me to troubleshoot such issues.