0

I created a maven project that worked with Java 8 and tested with Java 8 (pom specified 1.8).

To run this project in a machine with newer java (like Java 9) installed, I wonder shall the project run with newer java automatically since newer java is supposed to be backward compatible?

In general, I wonder what needs to be done to make a maven project work with newer Java releases.

Lily W
  • 1
  • 1
    Usually nothing. The exception would be if you have used a new reserved word (like `var`) in your source; when you recompile it there may be some changes needed under new versions. If you don't recompile, then it should continue to work (for the foreseeable future). – Elliott Frisch Apr 22 '19 at 23:52

1 Answers1

0

Not everything is backward compatible. Maven plugins like compiler is not. You need to do something as below [for java 11]:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
    <release>11</release>
</configuration>
</plugin>

And also generally speaking you should be updating your dependencies to its respective latest version. Please check the details in this article

Again, it would help if you mention a specific problem after you start running your old project as this stackoverflow question

For java 9, check this question

Mashrur
  • 535
  • 10
  • 22