Search code examples
javajvmversionmaven-central

Creating a new project for Maven Central - What JDK version to use?


Since JDK versions are not backward compatible, i.e. bytecode (*.class) files created with JDK X might not run under JVM X-1 or older (JDK 1.8 bytecode might not run on a JVM 1.5), how can I determine what version of Java should my project be built with if I want to submit it to Maven Central?

If I use the most recent Java and use its latest language feature, my project would not reach most users as the could not run my project with their JVM. However, I do not want to write my software with Java 1 neither. So, how does one determine the JDK version to use? What is the "standard", if there is any?


Solution

  • Java 7 is the answer, as of beginning of 2017.

    Nothing better than a survey to find out what version of Java is mainly used out there. The following Java Tools and Technologies Landscape Report 2016 article gives some really interesting insights. Apparently, 90% of projects in production use the last two versions of Java (as of this writing, Java 8 at 62% and Java 7 at 28%).

    Thus, for Maven Central, it is pretty safe to use the version just below the current one to reach most projects. Ashok Kumar N suggestion to use Java 7 makes perfect sense since it is strongly compatible with Java 6. Thus with Java 7, one can catch 99% of the market.