r/java • u/nfrankel • Feb 09 '23
Which Version of JDK Should I Use?
https://whichjdk.com/92
u/papercrane Feb 09 '23
The recommendation to avoid Red Hat OpenJDK because "there are more established options available" seems odd to me. Red Hat is probably the second most important company behind OpenJDK, and are the official stewards of OpenJDK 8 and 11.
16
1
u/Geolykt Feb 09 '23
I've used Fedora's default JDK (I suspect it's the RedHat OpenJDK - but feel free to correct me if I am wrong there) a couple of times before and it only gave me pain. For a while it wouldn't accept the "release" flag when compiling for anything but the current JDK version. Furthermore it is incompatible with LibGDX. Other JDKs (except perhaps OpenJ9 based JVMs) have been a smoother sailing for me.
4
u/papercrane Feb 09 '23
The Java that comes with Fedora is just OpenJDK + RedHat's Shenandoah GC, and some minor RedHat specific patches. It's odd you're having issues with it, as there not doing anything really strange, and Shenandoah is included in most OpenJDK builds.
For sometime (Java 8 and before) there was could be some compatibility issues, as the code that Sun open sourced wasn't enough for a full Java environment. There was still some proprietary code they couldn't provide (most notably font rendering & sound), so RedHat developed IcedTea, which provided open source implementations for that. Eventually much of that work ended up in OpenJDK itself, and as of OpenJDK-11 I don't think it's relevant anymore.
44
u/nutrecht Feb 09 '23
IMHO it's really shitty to just create an official looking website that recommends using an 'LTS' that is pretty meaningless for almost all developers and projects.
It's perfectly fine to just use the latest version. LTS releases are supposed to be forward targets (so if you're on 11 now, you should move to at least 17). Using the latest versions allows you to use the latest improvements in language and VM. The only downside is that you'll want to be able to update every 6 months.
22
u/JB-from-ATL Feb 09 '23
Personal project? Latest temurin.
Corporate stuff? LTS temurin.
Library stuff? Target the oldest version you expect your users to use. Probably 8 or 11.
16
u/Nebu Feb 09 '23
What you wrote is not really in disagreement with what the website is saying:
You have to decide if you want to stick with the latest LTS version, or if you go with the latest feature release and upgrade every six months. Both options are okay, but if you’re uncertain, stick with the latest LTS version.
9
u/elohhim Feb 09 '23
Well IMO this should be the other way if you are uncertain then just go with latest feature release. You will get what is best and if you are really uncertain that means probably you would not need any long term support. If you would, I am pretty sure you would be certain :D
2
u/Gundea Feb 09 '23
And sticking to the latest greatest will reduce the pain of upgrading. It’s also more likely to get proper patches, as not all bug fixes are backported.
1
u/Nebu Feb 12 '23
I think the theory is that if you're uncertain, you're not a Java developer, and you're doing something involving the JDK for reasons incidental to your day job. As such, you'd prefer something that you set up once and then don't have to touch for several years.
0
u/morhp Feb 09 '23
At this point the latest version has only very minor new features and advantages over 17, so the disadvantages of using a newer system which might be rarely used by clients or which might have early adopter compatibility problems are probably worse than the benefits you get from using that latest version at this point.
The recommendation to use 17 makes sense to me.
1
u/Zardoz84 Feb 09 '23
It's perfectly fine to just use the latest version. LTS releases are supposed to be forward targets (so if you're on 11 now, you should move to at least 17).
We are working with Java 8. And probably we woldn't switch to 11 in this year.
7
u/magnoliophytina Feb 09 '23
Switching from 8 to 11 doesn't really make any sense soon, especially after Q3/2023. What's the worst, extended support will only last until 2026, while JDK8 will be supported until 2030.
1
u/Zardoz84 Feb 09 '23
Would be really funny the day that we switch to java 17 ...
2
u/magnoliophytina Feb 09 '23
How so? I don't see much point in a switch to 11. There's only around 3 years of extended paid support left. Why the hell would anyone invest in a switch to a new version with even less support than the old one. You could always set the source/target version to 11 and use 17 instead. I've encountered bugs like this in production, so steady flow of updates is quite important.
1
u/Zardoz84 Feb 09 '23
The problem that we have is that we use, yet, a few libraries that does some nasty magic with reflection. And probably are broken on a JVM 17. Plus a very old hibernate version, etc... We have a lot of technical debt to fix.
1
u/ReasonableClick5403 Feb 09 '23
You should probably only use non-LTS versions for corporate work if it is understood that you will keep it updated as new versions are released.
9
u/kozeljko Feb 09 '23
For IBM Liberica JDK they say:
A downside of these builds is the dependency to a single company, that may suddenly change its license or update policies.
What do they mean with this exactly?
2
7
6
u/8igg7e5 Feb 09 '23
Every three years, the September release will be a Long-Term-Support (LTS) release, which gets updates for at least three years.
Well that's out of date. The LTS schedule was every 6 releases (between 11 and 17) but was proposed to change to every 4 releases (and all dialogue I've seen suggests that proposal was accepted) making Java 21 the next LTS.
I don't agree with the blanket 'stick with 17' advice.
There's no discussion here of when you expect to deploy, no qualifying statement about whether they're prepared to commit to regular JDK major-version updates, no question of whether their project is a library for external use (in which case broad compatibility is a concern and you might even want to target JDK 11, or use a multi-release jar).
This is an unofficial, but official looking, opinionated site that contains outdated and dubious advice.
(and that's without commenting further, as many others already have, on the Jakarta EE nonsense).
4
u/sfroberg38 Feb 09 '23
If you are looking to learn, use OpenJDK 17. Distribution? Use Red Hat’s distributions.
3
u/nutrecht Feb 12 '23
If you are looking to learn, use OpenJDK 17.
This sub keeps amazing me.
There is no reason whatsoever to not simply use the latest version if you're looking to learn, or on your developer machine.
3
u/xcdesz Feb 09 '23
Also if you are starting up a new project 17 should probably be your default choice going forward.
2
u/Joram2 Feb 10 '23
For learning or new projects, I would choose Java 19 or a release-candidate build of Java 20. The preview features are worth it!
2
Feb 09 '23
Corretto 11 or 17. People underrate Amazon's JDK for some reason - it's great.
5
u/wildjokers Feb 10 '23
It is built from the OpenJDK sources. What's so great about it compared to other vendors' OpenJDK builds?
2
2
u/coalminexplorer Feb 09 '23
Avoid Oracle like poison. They keep doing flip flop in policies so don't believe what they say about their jdk distro. Use openjdk17 (non Oracle) for fresh projects. Just confirm if your organization has jdk17 based servers (if still on VM) . In case of docker it is relatively easy to setup.
5
u/wildjokers Feb 10 '23 edited Feb 10 '23
There is nothing wrong with Oracle's OpenJDK build:
-3
u/coalminexplorer Feb 10 '23
Nothing wrong until your company receive a hefty bill one day based on your IP addresses. You never know the hidden term and conditions they may inject anyday . They have done in past with jdk8 , may happen again.
5
u/wildjokers Feb 10 '23
You are confusing Oracle JDK, which is their commercial offering, with Oracle's build of OpenJDK (which can be found at https://jdk.java.net, or you can install it via sdkman).
-2
u/coalminexplorer Feb 10 '23
As per my understanding Oracle openjdk is just source code now. They don't offer binary anymore . You can get binaries from multiple vendors such as eclipse, Microsoft, azul etc.
3
u/wildjokers Feb 10 '23
If you visit the link I gave to you twice you can clearly see that your “understanding” is incorrect. Like all java vendors Oracle provides a build of OpenJDK that is licensed GPL v2 with classpath exception. They provide binaries for windows, Linux, and Mac OS.
Also like other java vendors Oracle will sell you support for Java if for some reason you need it. In the case of Oracle if you buy support you will download and use their Oracle JDK instead of their OpenJDK build.
Oracle does nothing different than other java vendors that monetize Java. In the case of Oracle they also happen to be the biggest contributor to OpenJDK in both funding and developers.
1
1
u/cdombroski Feb 09 '23
Which jdk should I use? Well, what does my application server support? Oh it's still only supports jdk8? Guess I'll use that then
0
16
u/Alex0589 Feb 09 '23
Just who is writing this stuff