Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to fix Fatal error compiling: invalid target release: 1.8

This tutorial is writen for mac users, on windows I didn’t had this error.

When I tried to do a mvn compile. I got the following error:

You will get this error because you asked maven to compile in a higher JDK then your current JDK is. To see what your current JDK is, type the following command in your terminal:

When I typed this command, I got the following result:

What, 1.6? But if I run java -version, I got 1.8… Now, to fix this, open a second terminal. There you type the following commands:

After I did that, my result was:

I want jdk1.8.0_25.jdk to be my currentJDK so I changed the currentJDK by the following command:

If you copy/paste this code, don’t forget to change the jdk version to yours! Now If you run the code below again, you will notice that 1.8 is your current JDK now.

Try a mvn compile again and enjoy 😀

2 comments for “How to fix Fatal error compiling: invalid target release: 1.8

  1. Neer
    24/03/2015 at 19:43

    Shouldn’t the command to set the symlink be
    sudo ln -fhsv /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

  2. Aman
    08/05/2015 at 06:26

    Thank you. This solution works. Also, the ‘CurrentJDK’ softlink in the last step was incorrect and Neer corrected it.

    Thank you both for the solution!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: