1
votes

I am having problem compiling my tests with Java 8 on a Windows machine. When I compile and run tests within IntelliJ IDE there is no problem, but when I compile on the command line, I get a "Fatal error compiling: invalid target release: 1.8"

This works just fine:

> mvn clean compile

This fails:

> mvn clean test-compile

My pom.xml includes the following compiler plugin configuration:

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

I have the correct java version:

> java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Any help would be much appreciated.

1
what does JAVA_HOME say? - bmargulies
what it eht output of mvn --version ? - jmj

1 Answers

2
votes

make JAVA_HOME point to jdk8

export JAVA_HOME=/path/to/your/JDK8

and run it again

make sure mvn picks up JAVA_HOME to 8 by running

mvn --version

You should see something like

$ mvn --version | grep 'Java home'
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre