How can I make my library compilable in both JDK 1.8 and JDK 11?


#1

We are building a java/scala library and we want the ability to compile it in both JDK 1.8 and JDK 11.

With the introduction of modules in JDK 9, we are facing an issue where we need to provide an additional setting of --add-modules=java.se (due to an external library dependency) for java11 and which breaks things on java 8.

We have explored sbt-multi-release-jar but it doesn’t support java 11. Could someone please help us with any other ways of making our library compatible with both java versions?


#2

One approach would be to have two versions of your library. Version 9.Major.minor for java 9+, and Version 8.Major.minor for older vms