Set Java version in maven [UPDATED]

Since developers mostly use version control systems like SVN or GIT with their projects and use either ANT or MAVEN for building these projects there is mostly the question what to do with the Java version used in the project and every developer that can use this project would need to set the Java version in his build path every time he imported this project into his IDE. Since I use maven in my projects I thought “Why not tell maven which Java version I need”. Still, you need the version in your installed JREs (Preferences -> Java -> Installed JREs) but if you already did that you can tell maven to use it with the following code:

Source: maven-apache.org

Update your Project with Right-Click -> Maven -> Update Project and there you have it, now you can tell maven to manage your Java versions in your projects pom.xml.

UPDATE: I updated the code snippet to use Java 8

Leave a Comment