1
Linux Mint 20.3
   os.name = Linux
   os.arch = amd64
   os.version = 5.13.0-25-generic



 Java : 
    openjdk version "1.8.0_322"
    OpenJDK Runtime Environment (build 1.8.0_322-b06)
    OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

Maven 3.8.3


major version number of the class file format being used.[3]
Java SE 17 = 61 (0x3D hex),
Java SE 16 = 60 (0x3C hex),
Java SE 15 = 59 (0x3B hex),
Java SE 14 = 58 (0x3A hex),
Java SE 13 = 57 (0x39 hex),
Java SE 12 = 56 (0x38 hex),
Java SE 11 = 55 (0x37 hex),
Java SE 10 = 54 (0x36 hex),
Java SE 9 = 53 (0x35 hex),
Java SE 8 = 52 (0x34 hex),

In pom.xml

<dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>17</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>17</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17</version>
        </dependency>

In my class files:

package com.myproject;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import javafx.util.Pair; // error here

@SuppressWarnings("rawtypes")
public interface ManagedGroupCommonDao extends GenericDao<ManagedGroupCommon, Integer> {
    Map<Integer, List<Pair<Integer,Integer>>> findAllMgIdsAssociatedNsPairs();
    List<Integer> findMGsParentsIdsAssociatedToNS(int nsDbId);
    Map<Integer, List<Integer>> findMGsParentsIdsAssociatedPerNSesAsMap(Collection<Integer> nsDbIds);
    
}

But I get error:

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project persistence-face: Compilation failure
[ERROR] /com/myproject/server-persistence/persistence-face/src/main/java/ManagedGroupCommonDao.java:[10,19] cannot access javafx.util.Pair
[ERROR]   bad class file: /home/alexeij/.m2/repository/org/openjfx/javafx-base/17/javafx-base-17-linux.jar(javafx/util/Pair.class)
[ERROR]     class file has wrong version 55.0, should be 52.0
[ERROR]     Please remove or make sure it appears in the correct subdirectory of the classpath.

The project must build by OpenJDK 8. This is a client's requirement.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Alexei
  • 14,350
  • 37
  • 121
  • 240

1 Answers1

0

According to the official documentation (https://openjfx.io/openjfx-docs/)

In any case, for both options, it is required to have a recent version of JDK 16, or at least JDK 11.

you have to use Java 11 or higher. Unfortunatley, it won't work with Java 8 as OpenJFX is build with a byte code level for Java 11.

Older versions of Java will bundle JavaFX, so If you are Java 8 based, you do not need to declare dependencies towards JavaFX in Maven, see this question: JavaFX comes with JDK 8? (but this JFX version is outdated)

rzo1
  • 5,561
  • 3
  • 25
  • 64
  • @rz01 If use jdk 8 from BellSoft (Liberica JDK 8u322+6, LTS, Full JDK) , then success compile project. Url for download jdk8 - bell-sw.com/pages/downloads/#/java-8-lts – Alexei Feb 09 '22 at 09:43