Choosing a JDK to base your code on used to be so much easier when there was a new Java release only every decade or so… Now we get a new version of Java every six months. So which version should you use?
The first thing to understand is that not all JDK releases are created equal. Some of them are Long Term Releases (which will be supported for years to come) and others will be replaced after six months by Oracle (although other companies may offer longer term support). Long Term Releases were Java 8 and Java 11, while Java 9, 10 were short term (as is Java 12). Official end of support dates are on the Oracle website.
Later releases contain lots of features, which make it much easier and quicker to write good quality code. So there is a classic trade-off between new features and backwards compatibility.
So here are our personal suggestions…..
We need to write code which needs to use lots of legacy libraries and needs as few changes as possible
- Stick to Java 8. You get all the benefits of Lambdas and streams and Oracle will support for some years to come.
We are starting a new project and want to get all the benefits of modern Java but need some stability.
- Use Java 11. You get all the benefits of Lambda, streams, jigsaw and years of support.
We are starting a new project and want to get all the benefits of modern Java but development will take some time before we need to standardise
- Use Java 12/13 and aim to stabilise code use on Java 14 . You get the latest version of Java with a good long-term support timetable.
I personally would not recommend Java 9 or Java 10 unless you have very specific use cases (like we really want Java 8 plus jigsaw in which case you can create a multi-jar file and get both).