But you can also override the settings in a specific module. Change Java version for a multi-module Maven project:In case you have a multi-module Maven project, the sub modules will inherit the compiler source and target settings from the parent project. If you want to use the same Java version for both source and target, use the tag like this: This tells Java compiler to compile source code against Java version 11, and generate the. This is a little bit sad since obviously Java 8 had some nice features that you might want if you’re running Java 8, but the pre-Java-9 support. class files compatible with Java 10, with source code compatible to Java 8.Alternatively, you can also change Java version for a Maven project by configuring the Maven compiler plugin as follows: This works for Java 9 onwards so these multi-release JAR files will support a Java 9 version, a Java 10 (or 18.3), 11, 12 version etc but anything before Java 9 is lumped into pre-Java 9. It’s equivalent to using the –source and –target flags of Java compiler ( javac program).Note that the source version must be equal to or less than the target version. class files compatible with Java 1.8 as well. Then Maven will instruct Java compiler to compile source code against Java version 1.8, and generate. Simply declare the following properties in the pom.xml file: In this short post, I’d like to share with you guys how to change Java version for a Maven project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |