JavaFXPorts(Gluon)在Raspberry Pi上安装并运行一个简单的JFX程序

时间:2017-03-19 09:33:44

标签: raspberry-pi gluon javafxports gluon-mobile openjfx

我的硬件:

我的软件:

  • 操作系统: Raspbian GNU / Linux 8(jessie Lite)[Ohne X]
  • 内核: Linux 4.4.21 +
  • 架构: arm
  • 使用设备树覆盖激活触摸显示和Hifiberry
  • Java: jdk-8u121-linux-arm32-vfp-hflt
  • JavaFXPorts(Gluon):JavaFX Embedded SDK Version 8.60.8 armv6 hard float

到目前为止我做了什么:

首先,我从Oracel klick下载了当前的JDK版本(适用于Linux ARM 32 Hard Float ABI的Java 8u121)。

我将所有内容解压缩到/opt/

接下来我安装了新的Java版本......

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"

我现在进入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)

到目前为止看起来不错,不是吗?

其次,我从Gluon klick下载了当前版本的JavaFXPorts(JavaFX Embedded SDK Version 8.60.8 armv6 hard float)。

我将以下文件复制到JDK目录(/opt/jdk1.8.0_121)中,如2.1.4所述here

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 /臂/ * ------------------------------- JRE / LIB /臂/

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

我希望我在所有复制的文件中添加了正确的访问权限和组成员身份?

如上所述,我使用了Raspbian Lite,其中缺少Pango包。我已经阅读过OpenJFX klick我需要的内容。所以我用

安装了它
sudo apt-get install libpango-1.0-0:armhf libpangoft2-1.0-0:armhf

作为编程环境,我在家用电脑上运行 Netbeans 8.2

首先,我制作了一个正常的“Hallo World”程序,这对Raspberry Pi非常有用。

然后在家用电脑上用Netbeans构建一个非常简单的JavaFX Programm并转移到Raspberry Pi(到目录:/ 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);
    }

}

使用命令sudo java -jar JavaFXbasic.jar

从我的家用PC通过SSH执行

我总是在Raspberry Pi上看到这个错误 ...(注意: .jar-File正在我的家用电脑上运行!

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

我真的不明白来自Java的错误信息...我认为我做错了什么或忘了安装JavaFXPorts的东西?

我的系统现在如何知道OpenJFX?我没有运行任何安装命令或类似的...或编辑类路径。

感谢阅读

2 个答案:

答案 0 :(得分:4)

你安装了libgtk2.0-0吗?

sudo apt install libgtk2.0-0

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

答案 1 :(得分:0)

从bell-sw.com的人员那里检查构建。他们已将JDK与支持硬件加速的JavaFX模块捆绑在一起。

从以下位置获取一个:

https://bell-sw.com/pages/java-11.0.5%20for%20Embedded/

然后:

sudo dpkg --install bellsoft-jdk11.0.5+11-linux-arm32-vfp-hflt.deb

我已经在Raspbian Booster的RaspberryPi 3和4上成功测试了它们。享受吧!