JDK 8 vs. JDK 11+

I do know there is this JDK Compatibility page and it clearly says that it is recommended to BUILD Scala with JDK 8 whereas executing Scala applications on JRE 11+ should be fine.

In contrast, people usually say, that it is fine to build Scala on JDK 11+ as well, even if the support is not final and focus will be on JDK 8.

Starting a new project: What JDK is best practice? Fact is that I will need JavaFX/OpenJFX which makes the choosing of a Java version rather difficult.

I can’t say much about general JDK compatibility, but if you want to use JavaFX, you may want to look into ScalafFX (https://github.com/scalafx/scalafx/tree/stable). They have different releases for different JDKs / JavaFX versions, currently supporting up to JavaFX 12. So at least the FX part should work with the JDKs supported by ScalaFX.

PS: their homepage, https://www.scalafx.org, is a bit outdated and does not mention the newer versions than 8.0, but the JFX12 branch on Github is called “stable”.

1 Like

Thanks for your reply!

As far as I understand ScalaFX provides a wrapper to the JavaFX API. If I want to use OpenJFX 12 I need JDK 12. And if I want to use OpenJFX 12 with Scala I need Scala to support JDK 12, too.

But maybe I am wrong?

As I said, I’m not sure about limitations of Scala support for newer JDKs, but I’d assume, that if there is a Scala Wapper for OpenJFX12, then Scala itself should also mostly work.

If you want to be on the safe side, JDK8 is probably best, because it is long tested to work with Scala, while 11 and up are experimental, but you’d have to use JavaFX 8 too.

I would use JDK 8 and JavaFX 8 for now but since Oracle changed licensing I have to opt for an OpenJDK build and those usuall do not include JavaFX, and I believe there is no OpenJFX for JavaFX 8.

Their is a JavaFX for openJDK. Installation in Linux is straight forward. Don’t think it is as simple for Windows (colleague did not have success installing).

That being said, I think the compile with the LTS JDK11 should become a priority as JDK8 is being (has been?) phased out.

I would go to TLS JDK 11 but I just not manage to get over the Jigsaw thing with Scala and Gradle.