javamavenvaadin

"Unsupported class file error" on a Vaadin 14 project


I have an old Vaadin14 project that used to work with java 1.8.

I have upgraded my Linux distribution and now the java version 21.

The issue now is when I try to build the project (with mvn package -Pproduction), I get the following error:

[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:14.9.5:build-frontend (default) on project org-cubr-ui-vaadin: Execution default of goal com.vaadin:vaadin-maven-plugin:14.9.5:build-frontend failed: Unsupported class file major version 65 -> [Help 1]

So I installed java 1.8 and made it the default version with update-alternatives --config java but I have still the same error while building the project.

Question 1: Why maven doesn't use the java version configured with update-alternatives ? Do I have something to modify in the pom.xml file ?

Question 2: Is it even possible to build a Vaadin14/maven project on a recent distrib (I mean with a recent java version) ?


Update: when launching maven with option -X, I can see at the very beginning that java 21 is used.


Solution

  • You need to set JAVA_HOME environment variable to correct path.