Skip to content
Advertisement

Can a java 8 project depend on a java 11 dependency in gradle

I have a project in Java 8 and attempting to utilise a library written in Java 11. I am getting an error:

class file has wrong version 55.0, should be 52.0

Is this something that is basically not possible or is there some Gradle configuration which allows a Java 8 project to use a library written and compiled to Java 11?

Advertisement

Answer

The short answers is YES, you can use a Java 11 dependency in a Java 8 project.

The following error class file has wrong version 55.0, should be 52.0 happens when you are trying to load a Java class compiled with Java 11 in a Java 8 Runtime Environment, the version of the compiled class is incompatible with older runtime environment versions.

To be able to run your Java 8 project with the Java 11 dependency, you will need to run your project in a Java 11 Runtime Environment, in most cases this is possible without the need of changes to the source code (sometimes you will need to add explicitly some dependencies that were removed from Java 11 like Java EE and Corba modules).

Advertisement