TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Apache Maven

Specify Java version in a Maven Project.

Maven

Introduction

In this post, we will learn how to specify the Java version in the Maven pom.xml file. This is very useful when you are upgrading the Maven project to higher version of Java. Fixing errors during building Maven project. Example of one such error shown.

Sample Error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Sample: Compilation failure: Compilation failure:

[ERROR] Source option 5 is no longer supported. Use 7 or later.

[ERROR] Target option 5 is no longer supported. Use 7 or later.

Specifying Java version in POM

Configure the Maven compiler plugin in the POM.xml

<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>

Screenshot:

Source Target Version Java

 

We can cross check the settings in the Project settings window >> Java Compiler setting.

 

 

Maven Tutorials on this website can be found at:
https://www.testingdocs.com/apache-maven-tutorial/

For more details on the Apache Maven, visit the official website at:
https://maven.apache.org/

Related Posts

Maven Download Verification Win11

Apache Maven /

Download Maven on Windows 11

Invalid Target Java Error

Apache Maven /

Fix Fatal Error compiling: Invalid target release in Maven Project

Maven Project from archetype

Apache Maven /

Create Maven Project from Archetype in NetBeans

Create New Project

Apache Maven /

Create a Maven Project skip archetype

Maven Download Button

Apache Maven /

Install Maven on Ubuntu Linux

‹ Maven dependency management in Eclipse› Create Quickstart Maven Project in Eclipse IDE

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version