raspberry-pigluonjavafxportsgluon-mobileopenjfx

JavaFXPorts (Gluon) on Raspberry Pi installation and run a simple JFX-programm


My Hardware:

My Software:

What I have done so far:

First I downloaded the current JDK Version (Java 8u121 for Linux ARM 32 Hard Float ABI) from Oracel klick.

I unpacked everything to /opt/

Next I installed the new Java version ...

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0_121/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.8.0_121/bin/javac" 1


sudo update-alternatives --set "java" "/opt/jdk1.8.0_121/bin/java"
sudo update-alternatives --set "javac" "/opt/jdk1.8.0_121/bin/javac"

When I enter now java -version

pi@raspberrypi:/opt $ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode)

That looks good so far, doesn't it ?

Second I downloaded the current version of JavaFXPorts (JavaFX Embedded SDK Version 8.60.8 armv6 hard float) from Gluon klick.

I copied the following files into the JDK directory (/opt/jdk1.8.0_121) as described here under 2.1.4.

armv6hf-sdk/rt/lib/ext/jfxrt.jar------------------------jre/lib/ext/

i@raspberrypi:/opt/jdk1.8.0_121/jre/lib/ext $ ls -l
insgesamt 17140
-rw-r--r-- 1 uucp  143 3860502 Dez 13 02:40 cldrdata.jar
-rw-r--r-- 1 uucp  143    8286 Dez 13 02:40 dnsns.jar
-rw-r--r-- 1 uucp  143   44516 Dez 13 02:40 jaccess.jar
-rw-r--r-- 1 uucp  143 9771185 Mär 14 19:52 jfxrt.jar
-rw-r--r-- 1 uucp  143 1179093 Dez 13 02:40 localedata.jar
-rw-r--r-- 1 uucp  143     746 Dez 13 02:40 meta-index
-rw-r--r-- 1 uucp  143 2022531 Dez 13 02:40 nashorn.jar
-rw-r--r-- 1 uucp  143   42154 Dez 13 02:40 sunec.jar
-rw-r--r-- 1 uucp  143  280161 Dez 13 02:40 sunjce_provider.jar
-rw-r--r-- 1 uucp  143  251327 Dez 13 02:40 sunpkcs11.jar
-rw-r--r-- 1 uucp  143   68924 Dez 13 02:40 zipfs.jar

armv6hf-sdk/rt/lib/arm/*-------------------------------jre/lib/arm/

pi@raspberrypi:/opt/jdk1.8.0_121/jre/lib/arm $ ls -l
insgesamt 54520
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:43 client
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 jli
-rwxr-xr-x 1 uucp  143      620 Dez 13 02:40 jvm.cfg
-rwxr-xr-x 1 uucp  143    12458 Dez 13 02:40 libattach.so
-rwxr-xr-x 1 uucp  143    28475 Dez 13 02:40 libawt_headless.so
-rwxr-xr-x 1 uucp  143   603570 Dez 13 02:40 libawt.so
-rwxr-xr-x 1 uucp  143   384820 Dez 13 02:40 libawt_xawt.so
-rwxr-xr-x 1 uucp  143     8419 Dez 13 02:40 libbci.so
-rwxr-xr-x 1 uucp  143   175043 Dez 13 02:40 libdcpr.so
-rwxr-xr-x 1 uucp  143    61200 Mär 14 19:54 libdecora_sse.so
-rwxr-xr-x 1 uucp  143    17694 Dez 13 02:40 libdt_socket.so
-rwxr-xr-x 1 uucp  143   427804 Dez 13 02:40 libfontmanager.so
-rwxr-xr-x 1 uucp  143    49825 Mär 14 19:54 libfxplugins.so
-rwxr-xr-x 1 uucp  143    31428 Mär 14 19:54 libglass_monocle.so
-rwxr-xr-x 1 uucp  143    15946 Mär 14 19:54 libglass_monocle_x11.so
-rwxr-xr-x 1 uucp  143   194284 Mär 14 19:54 libglass.so
-rwxr-xr-x 1 uucp  143  1676215 Mär 14 19:54 libgstreamer-lite.so
-rwxr-xr-x 1 uucp  143   159094 Dez 13 02:40 libhprof.so
-rwxr-xr-x 1 uucp  143    42623 Dez 13 02:40 libinstrument.so
-rwxr-xr-x 1 uucp  143    43882 Dez 13 02:40 libj2gss.so
-rwxr-xr-x 1 uucp  143    13521 Dez 13 02:40 libj2pcsc.so
-rwxr-xr-x 1 uucp  143    68103 Dez 13 02:40 libj2pkcs11.so
-rwxr-xr-x 1 uucp  143     6527 Dez 13 02:40 libjaas_unix.so
-rwxr-xr-x 1 uucp  143    20825 Dez 13 02:40 libjava_crw_demo.so
-rwxr-xr-x 1 uucp  143    23301 Mär 14 19:54 libjavafx_font_freetype.so
-rwxr-xr-x 1 uucp  143    20564 Mär 14 19:54 libjavafx_font_pango.so
-rwxr-xr-x 1 uucp  143    14950 Mär 14 19:54 libjavafx_font.so
-rwxr-xr-x 1 uucp  143   218702 Mär 14 19:54 libjavafx_iio.so
-rwxr-xr-x 1 uucp  143   190543 Dez 13 02:40 libjava.so
-rwxr-xr-x 1 uucp  143     5704 Dez 13 02:40 libjawt.so
-rwxr-xr-x 1 uucp  143   255277 Dez 13 02:40 libjdwp.so
-rwxr-xr-x 1 uucp  143    23126 Dez 13 02:40 libjfr.so
-rwxr-xr-x 1 uucp  143   207761 Mär 14 19:54 libjfxmedia.so
-rwxr-xr-x 1 uucp  143 47082651 Mär 14 19:54 libjfxwebkit.so
-rwxr-xr-x 1 uucp  143   231488 Dez 13 02:40 libjpeg.so
-rwxr-xr-x 1 uucp  143    10601 Dez 13 02:40 libjsdt.so
-rwxr-xr-x 1 uucp  143     9365 Dez 13 02:40 libjsig.so
-rwxr-xr-x 1 uucp  143    66283 Dez 13 02:40 libjsoundalsa.so
-rwxr-xr-x 1 uucp  143     5789 Dez 13 02:40 libjsound.so
-rwxr-xr-x 1 uucp  143   331773 Dez 13 02:40 libkcms.so
-rwxr-xr-x 1 uucp  143   328967 Dez 13 02:40 liblcms.so
-rwxr-xr-x 1 uucp  143    48263 Dez 13 02:40 libmanagement.so
-rwxr-xr-x 1 uucp  143   738200 Dez 13 02:40 libmlib_image.so
-rwxr-xr-x 1 uucp  143   101978 Dez 13 02:40 libnet.so
-rwxr-xr-x 1 uucp  143    79517 Dez 13 02:40 libnio.so
-rwxr-xr-x 1 uucp  143    11385 Dez 13 02:40 libnpt.so
-rwxr-xr-x 1 uucp  143    42591 Mär 14 19:54 libprism_common.so
-rwxr-xr-x 1 uucp  143    59647 Mär 14 19:54 libprism_es2_eglfb.so
-rwxr-xr-x 1 uucp  143    54157 Mär 14 19:54 libprism_es2_monocle.so
-rwxr-xr-x 1 uucp  143    56508 Mär 14 19:54 libprism_sw.so
-rwxr-xr-x 1 uucp  143     8840 Dez 13 02:40 libresource.so
-rwxr-xr-x 1 uucp  143    53534 Dez 13 02:40 libsaproc.so
-rwxr-xr-x 1 uucp  143    23669 Dez 13 02:40 libsctp.so
-rwxr-xr-x 1 uucp  143   380853 Dez 13 02:40 libsplashscreen.so
-rwxr-xr-x 1 uucp  143   238184 Dez 13 02:40 libsunec.so
-rwxr-xr-x 1 uucp  143   408161 Dez 13 02:40 libt2k.so
-rwxr-xr-x 1 uucp  143   165565 Dez 13 02:40 libunpack.so
-rwxr-xr-x 1 uucp  143    46976 Dez 13 02:40 libverify.so
-rwxr-xr-x 1 uucp  143   110763 Dez 13 02:40 libzip.so
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:43 server

armv6hf-sdk/rt/lib/javafx.platform.properties-----jre/lib/

armv6hf-sdk/rt/lib/javafx.properties----------------jre/lib/

armv6hf-sdk/rt/lib/jfxswt.jar--------------------------jre/lib/

pi@raspberrypi:/opt/jdk1.8.0_121/jre/lib $ ls -l
insgesamt 72848
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 applet
drwxr-xr-x 5 uucp  143     4096 Mär 14 19:54 arm
-rw-r--r-- 1 uucp  143     1378 Dez 13 02:40 calendars.properties
-rw-r--r-- 1 uucp  143  3135391 Dez 13 02:40 charsets.jar
-rw-r--r-- 1 uucp  143    84311 Dez 13 02:40 classlist
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 cmm
-rw-r--r-- 1 uucp  143     5916 Dez 13 02:40 content-types.properties
-r--r--r-- 1 uucp  143     4122 Dez 13 02:40 currency.data
drwxr-xr-x 2 uucp  143     4096 Mär 14 19:52 ext
-rw-r--r-- 1 uucp  143     3901 Dez 13 02:40 flavormap.properties
-r--r--r-- 1 uucp  143     1678 Dez 13 02:40 fontconfig.bfc
-rw-r--r-- 1 uucp  143     1938 Dez 13 02:40 fontconfig.properties.src
-r--r--r-- 1 uucp  143     4532 Dez 13 02:40 fontconfig.RedHat.5.bfc
-rw-r--r-- 1 uucp  143     8841 Dez 13 02:40 fontconfig.RedHat.5.properties.src
-r--r--r-- 1 uucp  143     4250 Dez 13 02:40 fontconfig.RedHat.6.bfc
-rw-r--r-- 1 uucp  143     8735 Dez 13 02:40 fontconfig.RedHat.6.properties.src
-r--r--r-- 1 uucp  143     6702 Dez 13 02:40 fontconfig.SuSE.10.bfc
-rw-r--r-- 1 uucp  143    16772 Dez 13 02:40 fontconfig.SuSE.10.properties.src
-r--r--r-- 1 uucp  143     7032 Dez 13 02:40 fontconfig.SuSE.11.bfc
-rw-r--r-- 1 uucp  143    16781 Dez 13 02:40 fontconfig.SuSE.11.properties.src
-r--r--r-- 1 uucp  143     4668 Dez 13 02:40 fontconfig.Turbo.bfc
-rw-r--r-- 1 uucp  143     9192 Dez 13 02:40 fontconfig.Turbo.properties.src
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 fonts
-rw-r--r-- 1 uucp  143    13962 Dez 13 02:40 hijrah-config-umalqura.properties
drwxr-xr-x 3 uucp  143     4096 Dez 13 02:40 images
-rw-r--r-- 1 uucp  143      992 Mär 14 19:58 javafx.platform.properties
-rw-r--r-- 1 uucp  143       55 Mär 14 19:58 javafx.properties
-rw-r--r-- 1 uucp  143   116446 Dez 13 02:40 jce.jar
-rwxr-xr-x 1 uucp  143     7978 Dez 13 02:40 jexec
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 jfr
-rw-r--r-- 1 uucp  143   560581 Dez 13 02:40 jfr.jar
-rw-r--r-- 1 uucp  143      521 Mär 14 19:59 jfxswt.jar
-rw-r--r-- 1 uucp  143   647051 Dez 13 02:40 jsse.jar
-rw-r--r-- 1 uucp  143     4226 Dez 13 02:40 jvm.hprof.txt
-rw-r--r-- 1 uucp  143     2455 Dez 13 02:40 logging.properties
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 management
-rw-r--r-- 1 uucp  143      381 Dez 13 02:40 management-agent.jar
-rw-r--r-- 1 uucp  143     2034 Dez 13 02:40 meta-index
-rw-r--r-- 1 uucp  143     4464 Dez 13 02:40 net.properties
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 oblique-fonts
-rw-r--r-- 1 uucp  143    10393 Dez 13 02:40 psfontj2d.properties
-rw-r--r-- 1 uucp  143     2796 Dez 13 02:40 psfont.properties.ja
-rw-r--r-- 1 uucp  143  3505335 Dez 13 02:40 resources.jar
-rw-r--r-- 1 uucp  143 66152504 Dez 13 02:40 rt.jar
drwxr-xr-x 2 uucp  143     4096 Dez 13 02:40 security
-rw-r--r-- 1 uucp  143     1210 Dez 13 02:40 sound.properties
-rw-r--r-- 1 uucp  143   104311 Dez 13 02:40 tzdb.dat

I hope I added on all copied files the right access rights and group memberships ?

As mentioned above I use Raspbian Lite, where the Pango package is missing. I have read I need that for OpenJFX klick. So I installed it with

sudo apt-get install libpango-1.0-0:armhf libpangoft2-1.0-0:armhf

As programming environment I am using Netbeans 8.2 running on my home PC.

First I made a normal "Hallo World" Programm and that worked very good on the Raspberry Pi.

Then a very simpel JavaFX Programm build in Netbeans on my home PC and transfer to the Raspberry Pi (to dir: /home/pi/Netbeans)

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javafxbasic;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * @author zimt
 */
public class JavaFXbasic extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);

        Scene scene = new Scene(root, 320, 240);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

Executed from my home PC over SSH with the command sudo java -jar JavaFXbasic.jar

And I always see this Error on the Raspberry Pi ...(Note: The .jar-File is working on my home PC !)

Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
        at javafx.scene.Node.reapplyCss(Node.java:8983)
        at javafx.scene.Node.impl_reapplyCSS(Node.java:8946)
        at javafx.scene.Node.invalidatedScenes(Node.java:854)
        at javafx.scene.Node.setScenes(Node.java:919)
        at javafx.scene.Scene$9.invalidated(Scene.java:1119)
        at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
        at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
        at javafx.scene.Scene.setRoot(Scene.java:1072)
        at javafx.scene.Scene.<init>(Scene.java:347)
        at javafx.scene.Scene.<init>(Scene.java:223)
        at javafxbasic.JavaFXbasic.start(JavaFXbasic.java:37)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
        at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
        at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
        ... 1 more
Caused by: java.lang.NullPointerException
        at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:196)
        at javafx.scene.text.Font.<init>(Font.java:319)
        at javafx.scene.text.Font.getDefault(Font.java:86)
        at javafx.scene.CssStyleHelper.<clinit>(CssStyleHelper.java:1528)
        ... 19 more
Exception running application javafxbasic.JavaFXbasic

I don't really understand the error message from Java ... I think I did something wrong or forgot something installing JavaFXPorts ?

How does my system know there is OpenJFX now ? I have not run any install command or similar ... or edit the classpath.

thanks for reading


Solution

  • Did you install libgtk2.0-0 ?

    sudo apt install libgtk2.0-0

    Reference: https://www.raspberrypi.org/forums/viewtopic.php?t=133636&f=81