树莓派 armv几_如何在具有armv6处理器的树莓派板上安装和使用Java 11和JavaFX 11
樹莓派 armv幾
In a previous post “Installing Java and JavaFX on the Raspberry Pi”, you can read how to install BellSoft LibericaJDK to be able to run JavaFX applications with a graphical user interface on a Raspberry Pi with ARMv7 or ARMv8 processor.
在上一篇文章“在Raspberry Pi上安裝Java和JavaFX”中 ,您可以閱讀如何安裝BellSoft LibericaJDK以便能夠在具有ARMv7或ARMv8處理器的Raspberry Pi上以圖形用戶界面運行JavaFX應用程序。
But this won’t work for some (older) versions of the Raspberry Pi as these use an ARMv6 processor which is not compatible with the default OpenJDK 11 which is part of Raspbian OS.
但這不適用于某些(較舊)版本的Raspberry Pi,因為這些版本使用ARMv6處理器,該處理器與Raspbian OS的默認OpenJDK 11不兼容。
This post will guide you through the steps to have a working Java JDK and JavaFX 11 on these Raspberry Pi board versions.
這篇文章將指導您完成在這些Raspberry Pi電路板版本上運行Java JDK和JavaFX 11的步驟。
準備一個ARMv6 Raspberry Pi板 (Prepare an ARMv6 Raspberry Pi board)
For this post, I’m using an old Raspberry Pi B+ 1.2. To be sure which ARM-version is used, check the output of “cat /proc/cpuinfo” in the terminal:
對于這篇文章,我使用的是舊的Raspberry Pi B + 1.2。 要確定使用哪個ARM版本,請在終端中檢查“ cat / proc / cpuinfo”的輸出:
$ cat /proc/cpuinfoprocessor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 0010
Serial : 000000005f9ba615
Model : Raspberry Pi Model B Plus Rev 1.2
For a clear overview of the different board- and ARM-version, check this table on Wikipedia. The boards with ARMv6 are:
要清楚了解不同的Board版本和ARM版本,請查看Wikipedia上的此表 。 ARMv6的主板是:
- Raspberry Pi 1 A and A+ Raspberry Pi 1 A和A +
- Raspberry Pi 1 B and B+ Raspberry Pi 1 B和B +
- Compute Module 1 計算模塊1
- Zero 1.2, 1.3 and W 零1.2、1.3和W
使用Raspbian OS準備SD卡(完整) (Prepare SD card with Raspbian OS (Full))
We start with a fresh new Raspbian OS on the SD card using the “Imager” tool.
我們首先使用“ Imager”工具在SD卡上使用全新的Raspbian OS。
When we now boot the Rasberry Pi board with an ARMv6 processor and check the Java version we get this result:
現在,當我們使用ARMv6處理器啟動Rasberry Pi板并檢查Java版本時,將得到以下結果:
$ java -versionError occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP
As expected, the default included OpenJDK for ARM is build for version 7 or higher, so doesn’t work on this ARMv6-based Raspberry Pi B+ 1.2.
不出所料,默認包含的OpenJDK for ARM是為版本7或更高版本構建的,因此在基于ARMv6的Raspberry Pi B + 1.2上不起作用。
關于Java JDK (About Java JDK)
The sources of Java are available through the open-source project OpenJDK. So anyone can build Java JDK packages — yes you can even do it yourself! — and luckily a lot of free pre-build versions are available.
Java的源代碼可通過開源項目OpenJDK獲得 。 因此任何人都可以構建Java JDK軟件包-是的,您甚至可以自己做 ! —幸運的是,有許多免費的預構建版本可用。
安裝Azul提供的Java 11 for ARMv6 (Install Java 11 for ARMv6 provided by Azul)
Only Azul seems to provide an ARMv6 version with there Zulu JDK, which is available for free!
只有Azul似乎提供帶有Zulu JDK的ARMv6版本,該版本是免費的!
Let’s get it from their download page and extract it on our Raspberry Pi.
讓我們從他們的下載頁面獲取它,并將其解壓縮到我們的Raspberry Pi中。
$ 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
OK, there it is! A new JDK on our board. Now let’s configure the OS to be aware of this new one.
好,那里! 我們板上的一個新JDK。 現在,我們將操作系統配置為了解這一新操作系統。
$ 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
Now we can select the new JDK so it’s linked to the “java” and “javac” command.
現在,我們可以選擇新的JDK,以便將其鏈接到“ java”和“ javac”命令。
$ sudo update-alternatives --config javaThere 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
If everything went well, we should be able to check the Java version now…
如果一切順利,我們現在應該可以檢查Java版本…
$ java -versionopenjdk 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)
We have a winner! We now successfully replaced the default OpenJDK 11 (which only works on ARMv7+) with the Azul Zulu JDK which works on ARMv6.
我們有贏家! 現在,我們成功地將默認的OpenJDK 11(僅適用于ARMv7 +)替換為適用于ARMv6的Azul Zulu JDK。
使用未編譯的Java文件進行測試 (Testing with a non-compiled Java file)
Let’s try out the newly installed Java JDK. Since Java 11, we can run Java-files directly without the need to compile them. Let’s create a simple file with nano and run it.
讓我們嘗試一下新安裝的Java JDK。 從Java 11開始,我們無需編譯即可直接運行Java文件。 讓我們用nano創建一個簡單的文件并運行它。
$ cd /home/pi$ nano HelloWorld.java
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello World");
}
}
$ java HelloWorld.java
Hello World
Perfect! Java works as expected, but it takes about 15 seconds before the “Hello World” is shown on this old board dating from 2014.
完善! Java可以按預期工作,但是要花15秒鐘的時間才能在2014年的舊主板上顯示“ Hello World”。
JavaFX圖形用戶界面 (Graphical user interfaces with JavaFX)
If you also want to use JavaFX user interfaces, additional steps are needed as this library is not included in the JDK 11. It is developed as an independant open-source project on openjfx.io. The main contributor and maintainer is Gluon. They also offer commercial support to companies who want to use JavaFX for desktop and mobile application development.
如果您還想使用JavaFX用戶界面,則需要額外的步驟,因為JDK 11中不包含該庫。它是作為openjfx.io上的獨立開源項目開發的 。 主要貢獻者和維護者是Gluon 。 他們還為希望使用JavaFX進行桌面和移動應用程序開發的公司提供商業支持 。
Make sure you successfully updated to Azul Zulu JDK 11 before proceeding with the next steps.
在繼續下一步之前,請確保您已成功更新到Azul Zulu JDK 11。
安裝GluonHQ提供的Javav 11 for ARMv6 (Install JavaFX 11 for ARMv6 provided by GluonHQ)
We are going to use the free public version provided by Gluon on their download page.
我們將在其下載頁面上使用Gluon提供的免費公共版本。
$ cd /home/pi$ wget -O javafx.zip https://gluonhq.com/download/javafx-11-0-2-sdk-armv6hf/
$ unzip javafx.zip
$ rm javafx.zip
We can now check the JavaFX library which was unpacked in “armv6hf-sdk”:
現在,我們可以檢查在“ armv6hf-sdk”中解壓縮的JavaFX庫:
pi@raspberrypi:~ $ ls -ltotal 44
drwxr-xr-x 4 pi pi 4096 Mar 12 2019 armv6hf-sdk
drwxr-xr-x 2 pi pi 4096 Aug 20 11:40 Bookshelf
drwxr-xr-x 2 pi pi 4096 Aug 20 12:10 Desktop
...
$ ls -l armv6hf-sdk/
total 8
drwxr-xr-x 8 pi pi 4096 Mar 12 2019 legal
drwxr-xr-x 2 pi pi 4096 Mar 12 2019 lib
$ ls -l armv6hf-sdk/lib/
total 17124
-rw-r--r-- 1 pi pi 845637 Mar 12 2019 javafx.base.jar
-rw-r--r-- 1 pi pi 2761905 Mar 12 2019 javafx.controls.jar
-rw-r--r-- 1 pi pi 143926 Mar 12 2019 javafx.fxml.jar
-rw-r--r-- 1 pi pi 5270589 Mar 12 2019 javafx.graphics.jar
-rw-r--r-- 1 pi pi 294822 Mar 12 2019 javafx.media.jar
-rw-r--r-- 1 pi pi 992 Mar 12 2019 javafx.platform.properties
-rw-r--r-- 1 pi pi 113 Mar 12 2019 javafx.properties
-rw-r--r-- 1 pi pi 41802 Mar 12 2019 javafx-swt.jar
-rw-r--r-- 1 pi pi 786021 Mar 12 2019 javafx.web.jar
-rwxr-xr-x 1 pi pi 61200 Mar 12 2019 libdecora_sse.so
-rwxr-xr-x 1 pi pi 31428 Mar 12 2019 libglass_monocle.so
-rwxr-xr-x 1 pi pi 15946 Mar 12 2019 libglass_monocle_x11.so
-rwxr-xr-x 1 pi pi 200074 Mar 12 2019 libglass.so
-rwxr-xr-x 1 pi pi 22409 Mar 12 2019 libjavafx_font_freetype.so
-rwxr-xr-x 1 pi pi 20508 Mar 12 2019 libjavafx_font_pango.so
-rwxr-xr-x 1 pi pi 15206 Mar 12 2019 libjavafx_font.so
-rwxr-xr-x 1 pi pi 231402 Mar 12 2019 libjavafx_iio.so
-rwxr-xr-x 1 pi pi 43339 Mar 12 2019 libprism_common.so
-rwxr-xr-x 1 pi pi 54506 Mar 12 2019 libprism_es2_monocle.so
-rwxr-xr-x 1 pi pi 56505 Mar 12 2019 libprism_sw.so
-rw-r--r-- 1 pi pi 6598638 Mar 12 2019 src.zip
使用最小的JavaFX應用程序進行測試 (Test with a minimal JavaFX application)
We are going to reuse the minimal JavaFX application which was created in this post “PiJava — Part 4 — Building a minimal JavaFX 11 application with Maven”. First, we need to clone the sources from GitHub:
我們將重復使用本文“ PiJava-第4部分-使用Maven構建最小的JavaFX 11應用程序”中創建的最小的JavaFX應用程序 。 首先,我們需要從GitHub克隆源:
$ cd /home/pi$ git clone https://github.com/FDelporte/MinimalJavaFx11Application.git
To be able to build the application, we also need Maven to be installed.
為了能夠構建應用程序,我們還需要安裝Maven。
$ sudo apt install mavenNow let’s build the application:
現在讓我們構建應用程序:
$ cd MinimalJavaFx11Application$ mvn clean package
This will take some time as all the dependencies need to be downloaded.
這將需要一些時間,因為需要下載所有依賴項。
When finished, we can now run the application with the following start command which points to the downloaded JavaFX library and the generated jar-application in the out-directory of “MinimalJavaFx11Application”:
完成后,我們現在可以使用以下啟動命令運行該應用程序,該命令指向下載的JavaFX庫和“ MinimalJavaFx11Application”的輸出目錄中生成的jar應用程序:
$ sudo java --module-path /home/pi/armv6hf-sdk/lib--add-modules=javafx.controls
-jar /home/pi/MinimalJavaFx11Application/out/MinimalJavaFx11Application-0.1-SNAPSHOT.jar
And there we have it! JavaFX running on an ARMv6 Raspberry Pi B+ 1.2!!!
我們終于得到它了! 在ARMv6 Raspberry Pi B + 1.2上運行的JavaFX !!!
結論 (Conclusion)
Compared to the latest Raspberry Pi with a much faster processor and more memory, the application starts a lot slower on my 6-year old test board. But it works! Yes, really, it works :-)
與具有更快處理器和更多內存的最新Raspberry Pi相比,在我使用了6年的測試板上,該應用程序的啟動速度要慢得多。 但這有效! 是的,真的,它有效:-)
Again this small-superhero-board proves to be able to handle everything, even the most modern Java versions on an old processor.
再次證明了這種小型超級英雄板能夠處理所有內容,即使是舊處理器上最現代的Java版本也是如此。
And, if you like video, here is the video from Javarevisited Youtube Channel on how to install Java on Raspberry PI
而且,如果您喜歡視頻,這是Javarevisited Youtube Channel上有關如何在Raspberry PI上安裝Java的視頻。
And, If you like this video and want to learn more you can also check the full course here — Use Java and Java FX on a Raspberry PI
而且,如果您喜歡此視頻并希望了解更多信息,還可以在此處查看完整的課程- 在Raspberry PI上使用Java和Java FX
Originally published at https://webtechie.be.
最初發布在 https://webtechie.be 。
翻譯自: https://medium.com/javarevisited/how-to-install-and-use-java-11-and-javafx-11-on-raspberry-pi-boards-with-armv6-processor-ca7109b76b7c
樹莓派 armv幾
總結
以上是生活随笔為你收集整理的树莓派 armv几_如何在具有armv6处理器的树莓派板上安装和使用Java 11和JavaFX 11的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python办公自动化——批量合并wor
- 下一篇: 58失去“神奇”魔法