如何在Raspberry Pi OS上安装JavaFX

huangapple go评论81阅读模式
英文:

How to install JavaFX on Raspberry Pi OS

问题

我想在树莓派1型号B上使用JavaFX包运行.jar文件。
在ARM架构的JDK 8版本中不包含JavaFX。因此,我尝试按照以下网站的参考安装JavaFX。
https://stackoverrun.com/ja/q/11146620

我成功安装了JDK,并将从zip归档中提取的文件移动到所需的JDK文件夹中。
在此之后,我尝试运行了两个.jar文件。其中一个.jar文件的GUI由Swing包组成,另一个由JavaFX包组成。
由Swing包组成的.jar文件运行良好,如下图所示。
树莓派上的Swing

另一方面,由JavaFX包组成的.jar文件输出错误或警告,如下图所示。
树莓派上的JavaFX

在这些输出之后,显示了没有标题栏的异常GUI。因此,无法最小化、最大化/调整大小、关闭和移动窗口。
此外,窗口的周围被填充为黑色。
树莓派上显示的JavaFX窗口

当然,已确认这两个.jar文件在Windows 10环境下的Java 8上运行良好,没有错误。
Windows 10上的Swing
Windows 10上的JavaFX

注意:正如您所知,Windows版的Java 8版本最初包含JavaFX库。

我想解决这个问题。
我的当前操作系统和Java信息如下。
运行环境

非常感谢您的时间。

英文:

I want to run .jar file with JavaFX packeages on Raspberry PI 1 Model B.
JavaFX is not included in JDK 8 version for ARM. Hence I tried to install JavaFX by reference to the following web site.
https://stackoverrun.com/ja/q/11146620

I succeeded to install JDK and move extracted files form a zip archive to JDK required folders.
I tried to run two .jar files after that. The GUI of one .jar file is consisted of Swing package, the other is consisted of JavaFX package.
The .jar file consisted of Swing package worked well, as shown in the following figure.
Swing on Raspbian

On the other hand, the .jar file consisted of JavaFX package outputs errors or warnings as shown in the following figure.
JavaFX on Raspbian

After these outputs, abnomal GUI without titlebar was desplayed. Consequently, minimizing, maxmizing/resizing closing and moving window are unable.
Additionally, surroundings of window is filled with black.
Displayed window of JavaFX on Raspbian

Of cource it is confirmed that these two .jar files worked well on Java 8 on windows 10 environment without errors.
Swing on Windows 10
JavaFX on Windows 10

Note:As you know, Java 8 version for windows includes JavaFX libraries originally.

I want to solve this problem.
My current OS and Java information is shown below.
Running Environment

Thanks so much for your time.

答案1

得分: 0

Indeed almost all Linux JDKs for ARM now are for 64bit.

But Azul has a Zulu JDK you can start from: Zulu Community

$ cd /usr/lib/jvm
$ sudo wget https://cdn.azul.com/zulu-embedded/bin/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo tar -xzvf zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo rm zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ ls -l
total 12
lrwxrwxrwx  1 root root   21 Jul 23 15:58 java-1.11.0-openjdk-armhf -> java-11-openjdk-armhf
drwxr-xr-x  9 root root 4096 Aug 20 11:41 java-11-openjdk-armhf
drwxr-xr-x  2 root root 4096 Aug 20 11:41 openjdk-11
drwxrwxr-x 10  111  122 4096 Jul 10 16:50 zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac 1

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                                             Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-armhf/bin/java                       1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/java                       1111      manual mode
  2            /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java   1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java to provide /usr/bin/java (java) in manual mode

$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                                              Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac                       1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac                       1111      manual mode
  2            /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac   1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac to provide /usr/bin/javac (javac) in manual mode

$ java -version
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Zulu11.41+75-CA (build 11.0.8+10-LTS)
OpenJDK Client VM Zulu11.41+75-CA (build 11.0.8+10-LTS, mixed mode)

Next step is installing JavaFX from Gluon JavaFX > "JavaFX armv6hf SDK"

$ cd /home/pi
$ wget -O javafx.zip https://gluonhq.com/download/javafx-11-0-2-sdk-armv6hf/
$ unzip javafx.zip
$ rm javafx.zip

When this is done, you can run your application with the following command:

$ sudo java --module-path /home/pi/armv6hf-sdk/lib --add-modules=javafx.controls -jar YOUR-APP.jar

For the full step-by-step, check this article on my blog: Azul Zulu Java 11 and Gluon JavaFX 11 on ARMv6 (Raspberry Pi)

英文:

Indeed almost all Linux JDKs for ARM now are for 64bit.

But Azul has a Zulu JDK you can start from: https://www.azul.com/downloads/zulu-community/?version=java-11-lts&amp;os=linux&amp;architecture=arm-32-bit-hf&amp;package=jdk

$ cd /usr/lib/jvm
$ sudo wget https://cdn.azul.com/zulu-embedded/bin/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo tar -xzvf zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ sudo rm zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz
$ ls -l
total 12
lrwxrwxrwx  1 root root   21 Jul 23 15:58 java-1.11.0-openjdk-armhf -&gt; java-11-openjdk-armhf
drwxr-xr-x  9 root root 4096 Aug 20 11:41 java-11-openjdk-armhf
drwxr-xr-x  2 root root 4096 Aug 20 11:41 openjdk-11
drwxrwxr-x 10  111  122 4096 Jul 10 16:50 zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac 1

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                                             Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-armhf/bin/java                       1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/java                       1111      manual mode
  2            /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java   1         manual mode

Press &lt;enter&gt; to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java to provide /usr/bin/java (java) in manual mode

$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                                              Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac                       1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac                       1111      manual mode
  2            /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac   1         manual mode

Press &lt;enter&gt; to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac to provide /usr/bin/javac (javac) in manual mode

$ java -version
openjdk version &quot;11.0.8&quot; 2020-07-14 LTS
OpenJDK Runtime Environment Zulu11.41+75-CA (build 11.0.8+10-LTS)
OpenJDK Client VM Zulu11.41+75-CA (build 11.0.8+10-LTS, mixed mode)

Next step is installing JavaFX from https://gluonhq.com/products/javafx/ > "JavaFX armv6hf SDK"

$ cd /home/pi
$ wget -O javafx.zip https://gluonhq.com/download/javafx-11-0-2-sdk-armv6hf/
$ unzip javafx.zip
$ rm javafx.zip

When this is done, you can run your application with the following command:

$ sudo java --module-path /home/pi/armv6hf-sdk/lib --add-modules=javafx.controls -jar YOUR-APP.jar

For the full step-by-step, check this article on my blog: https://webtechie.be/post/2020-08-27-azul-zulu-java-11-and-gluon-javafx-11-on-armv6-raspberry-pi/

huangapple
  • 本文由 发表于 2020年8月26日 18:59:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63596171.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定