相关文章推荐

I’ve just acquired a new Mac and was in the process of setting up a completely fresh environment on it (didn’t do a backup/restore of previous data). I installed brew and was looking at all the AdoptOpenJDK options available. My previous environment was running Java 8 and I didn’t ever have a need to upgrade it thus far, but this new machine is forcing me to make a decision. So, what’s the “best” Java version for Clojure at this point? Is it completely a “don’t care” since Clojure 1.10 just targets Java 8, or are there stability, performance, or other advantages to, say, Java 11+?

Thoughts?

I have some instructions I started writing up, which include how to install multiple JDK versions on a Linux or macOS system, and switch between them easily, that is pretty much common between those two operating systems (i.e. there isn’t really anything macOS-specific about it). https://github.com/jafingerhut/jafingerhut.github.com/blob/master/clojure/setup.md
They are not complete for my original purposes I started writing them, but should be complete for the JDK install part.

Just about any JDK version 8 or 11 are the most recommended right now, since both are widely used, and both under long term support from Oracle and multiple OpenJDK distributors.

If you want to use Cognitect’s REBL, I have had success on macOS using Zulu OpenJDK 8 and 11 if you get the “JDK FX” versions that include OpenJFX libraries bundled with them, and those work for both Linux and macOS for that purpose.

I use Zulu JDK 8, since it bundles JavaFx with it.

The performance between all JDK of the same version will be equal. Zulu doesn’t contain a different GC. I think you’re thinking of their paid JDK.

Their webpage is actually pretty good on comparing the different JDK: https://www.azul.com/products/zulu-enterprise/jdk-comparison-matrix/

I think that if you go with JDK 9+,like 11 or 13, there are more shenanigans to get some things working sometimes with the new modules. You could have some older library for example that doesn’t work with it.

For performance, I think unless you plan to experiment with the new experimental GCs it won’t matter much.

My recommendation: JDK 8 that is available with your package manager, if that’s AdoptOpenJDK go with that. And Zulu if you need OpenFX.

The only thing that comes to mind is there is a potential performance difference if you run your app in public cloud/containers. With JDK8 you need to set some experimental heap/memory flags manually:

-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

With JDK10+ they are enabled by default:

https://banzaicloud.com/blog/java10-container-sizing/

I guess it just means you get better performance out of the box with less configuration, as these flags are still available on JDK8 you just need to remember to turn them on. :sweat_smile:

Thanks for the info, folks. I settled on AdoptOpenJDK 11 since it’s LTS and has got support for Brew. I’ll try that, @didibus , and if I run into any problems, per your comments, I’ll switch back to Java 8. Right now, I don’t need JavaFx, and Zulu is a bit more trouble to install and manage long term ( brew upgrade is really nice). Maybe I’ll try it down the road.

@daver

I am glad you opted for AdoptOpenJDK. For what its worth, merely the effort of what this project constitute deserve attention - the project fills an important gap in the JVM echosystem.

Regards, Henning

 
推荐文章