java: error: release version 5 not supported

While building a new maven java project, sometimes the below error occurs:

Solution:

Add the following Maven compiler plugin to pom.xml

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

Also change the Java version on the following places in IntellijIdea:

Open Module Settings(F4) -> Project Settings -> Project -> Project SDK

Open Module Settings(F4) -> Project Settings -> Modules -> Sources -> Language level

 

File -> Settings (ctrl+alt+s) -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version

Module -> Target bytecode version

Share

Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *