7

I have a JavaFX 8 project which I develop on Windows 10 with NetBeans 8.2. The JAR I build from this I have running on an Asus Tinker Board.

With JDK 11 and JavaFX 11 I want to take advantage of a few of the new features and hope for some performance gain. After installing NetBeans 10 and with the help of the tutorial: https://openjfx.io/openjfx-docs/#introduction (section JavaFX and NetBeans > Non-modular with Maven), I have successfully ported and can run the application on my Windows system.

Either via the IDE or with the command prompt: java --module-path %PATH_TO_FX% --add-modules=javafx.c ontrols,javafx.fxml,javafx.graphics,javafx.media -jar Praatpaal2-2.0-jar-with-dependencies.jar

Compared to JavaFX 8, the JavaFX modules are now added as modules.

But when I do the same on the Asus Tinker Board (runnning Tinker OS (Debian)), I get the following error:

Error occurred during initialization of boot layer java.lang.module.FindException: Hash of javafx.base (d87df23ee5c54c7ff062c4f8572bab8aaf6c1775854662008fccdb993957bcad) differs to expected hash (320c5b0ffaf22fec9daf0c3e364f6598631b333fa95015a0f055e1c1c597c05b) recorded in java.base

There is very little information on this hash mismatch. My suspicion is that it either tries to load the Windows version of javafx.base.jar, or I use org.openjfx in the Maven pom.xml but refer to GluonHQ JavaFX on runtime, or there is something wrong with the modular setup I have.

The dependencies and build part of the pom.xml look like this:

<dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
            <classifier>win</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
            <classifier>win</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>11.0.2</version>
            <classifier>win</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>11.0.2</version>
            <classifier>win</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11.0.2</version>
            <classifier>linux</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11.0.2</version>
            <classifier>linux</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>11.0.2</version>
            <classifier>linux</classifier>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>11.0.2</version>
            <classifier>linux</classifier>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>
        <dependency>
            <groupId>net.samuelcampos</groupId>
            <artifactId>usbdrivedetector</artifactId>
            <version>2.0.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>nl.embeddedfitness.praatpaal2.Main</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <archive>
                            <manifest>
                                <mainClass>
                                    nl.embeddedfitness.praatpaal2.Main
                                </mainClass>
                            </manifest>
                            </archive>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

I have tried the 4 JavaFX dependencies with and without classifier. But this makes no difference. The jar-with-dependencies builds the jar with all dependencies except the JavaFX ones which I add on runtime with the java command I mentioned earlier.

For Java 11 I use:
https://bell-sw.com/pages/java-11.0.2
Microsoft Windows 64 bit for the Windows system
Linux ARMv7&8 32 Bit HardFloat for the Asus Tinker Board

For JavaFX 11 I use:
https://gluonhq.com/products/javafx/
JavaFX Windows SDK for the Windows system
JavaFX armv6hf SDK for the Asus Tinker Board

Fleximex
  • 111
  • 9
  • 2
    Can you try to run _without_ `module-path` and `add-modules` in your embedded device, just `java -jar Praatpaal2-2.0-jar-with-dependencies.jar` – José Pereda Mar 22 '19 at 09:18
  • @JoséPereda On the Tinker Board (as well as on the Windows system) this results in the expected "Error: JavaFX runtime components are missing, and are required to run this application" error. – Fleximex Mar 22 '19 at 09:30
  • 1
    On Windows, that is expected, of course, but not on the board, if you are using Bellsoft JDK. – José Pereda Mar 22 '19 at 09:32
  • 1
    Also make sure you don't bundle the JavaFX dependencies with your jar. – José Pereda Mar 22 '19 at 09:39
  • @JoséPereda I had the lite variant (without JavaFX packages installed). With the full version I now got it start. The system freezes but that's an other issue I will look into. It is kinda weird as I assumed it would still work as long as you point to JavaFX packages. For Media I can use the add-modules to point to the GluonHQ one (since the Bellsoft doesn't has that module for the ARM build). Thank your for your help! – Fleximex Mar 22 '19 at 09:57
  • 2
    The problem is that regular JavaFX packages won't work on ARM devices. Bellsoft lite version doesn't include JavaFX for ARM, and you can get it from [here](https://gluonhq.com/products/javafx/), but the full version doesn't include media or web, nor does Gluon's one, I'm afraid. For starters, try to disable the media part. – José Pereda Mar 22 '19 at 10:02
  • @JoséPereda The Gluon One doesn't include media? The zip of the 'JavaFX armv6hf SDK' variant does contain Media and WebKit jars though? – Fleximex Mar 22 '19 at 10:08
  • The native libraries are not included. That's the problem... You'll need a built of OpenJFX for ARM with media and web enabled. – José Pereda Mar 22 '19 at 10:09
  • Please don't add things like "solved" to a question title, nor should you add the solution to your question. If you managed to solve your problem on your own, then post an answer to your question describing the solution. After the timeout you can accept this answer to indicate the question is resolved. – Mark Rotteveel Mar 22 '19 at 10:19

1 Answers1

1

With the help of José Pereda I remembered I installed the lite version of Bellsoft JDK without the JavaFX modules. I now have the full version with those modules. I assumed I didn't need those since I would refer to the GluonHQ Java FX packages (--add-modules) anyway.
Bellsoft does not contain JavaFX Media so I will now try to use the Bellsoft JDK Java FX modules but add only the Media via --add-modules, though it may be that Media simply does not exist/work for ARM (yet).

Fleximex
  • 111
  • 9