Build error

Hi, I’m trying to build with mvn package -Pproduction, but I get the error in the image attached. How can I solve?

You’re using a unsupported Java version, probably Java 20 if I understand the message correctly

You should probably use Java 17 instead. Maybe the latest Vaadin 14 version is compatible with Java 20, but I think someone will answer it.

In the project settings I have set the sdk 1.8


Also check your pom.

also set to 1.8

Hard to say what you have done or haven’t done. If it works without an IDE involved, you probably have missed a configuration there

This looks like for some reason maven compiled your project with Java 20 (File Major Version 64)
I’d add these properties to the pom to make sure maven uses Java 17. Also make sure you have Java 17 installed. Clean your project (mvn clean) and try again.


In your IDE, you can also run mvn -v which should print the default java version maven has picked up

This is how it should look:

It’s set to 20 …how can change it?

Usually, the properties of the pom.xml should change it. If you want to change the default Java version maven uses, you need to change JAVA_HOME in your system environment variables

After adjusting your environment variables, you also need to restart your IDE/Command Line to make sure the changes are picked up

I updated the pom, but Java version doens’t change. I’m trying to change the default value of JAVA_HOME but when run mvn -v it return 20

The problem is that your IDE may also overwrite JAVA_HOME itself

You could theoretically temporarily remove your java 20 installation

or you need to figure out in which settings of your IDE the java version is set

but assuming you have java 17 installed and maven can find it, adding the maven.compiler.source and properties to the pom.xml should be enough for maven to compile it correctly