-1

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?

Community
  • 1
  • 1
Hans Deragon
  • 504
  • 1
  • 7
  • 17
  • Do you want to use streams and lambdas? Then go for Java 8. If not, go for Java 7. – Thorbjørn Ravn Andersen Apr 18 '17 at 18:31
  • You get to choose since you're the author. You can think "do I want to write modern code?" or "do I want to support people who are stuck in the 90's with their outdated JDK?". If you're worried about losing users because you're using Java 8, then you're probably having too high thoughts about your product. Besides, you can always backport it in case it suddenly becomes widely popular. – Kayaman Apr 18 '17 at 19:04
  • Why the downvote? I believe my question is valid. Anyone care to explain? – Hans Deragon Apr 19 '17 at 18:23
  • There is no definitive/valid answer to this question. It's entirely up to you. – Peter Lawrey Apr 20 '17 at 09:09

2 Answers2

1

its better to give it in java 7 so that it can be used in 6 to 8 version but you will lose some Functional Programming apporach

Ashok Kumar N
  • 573
  • 6
  • 23
  • What you are saying is that [http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#incompatibilities](Java SE 7 is strongly compatible with previous versions of the Java platform), thus a good compromise. By using Java 7, one can cater the Java 6 and Java 8 people easily. Java 5, not sure (I have not checked). How many projects are still running in Java 5 out there? – Hans Deragon Apr 19 '17 at 18:28
1

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.

Community
  • 1
  • 1
Hans Deragon
  • 504
  • 1
  • 7
  • 17