[英]Can JavaFX be used on Raspberry Pi
我想使用 JavaFX 為 Raspberry Pi 編寫程序,但似乎我的 Raspberry Pi 上的 Java SDK 8 不支持 JavaFX。
所以我的問題是Raspberry Pi 2/3
是否支持 JavaFX? 如果是,為什么 JDK 在平台上沒有 JavaFX 庫? 有沒有辦法支持它或值得在 Raspberry PI 上編寫 JavaFX 應用程序?
使用的 Java 版本是1.8.0_65
。
如果您使用Oracle JDK for ARM 8u33 / Oracle Java SE Embedded 8u33
或更高版本,您將找不到捆綁在 JDK 中的 JavaFX。 從 8u33 開始,Oracle 從 ARM 捆綁包中刪除了 JavaFX Embedded。 有關更多信息,請查看OpenJFX 郵件列表中的此主題。
那么,我們還可以在 Raspberry PI 上使用 JavaFX 嗎?
嗯,當然可以。 以下是您仍然可以在嵌入式設備上運行 JavaFX 的幾種方法:
你最好的拍攝是安裝嵌入SDK,通過provied膠子,其中包括jfxrt.jar
為ARM。 您可以將 jar 復制到 JDK 中,並在 Raspberry PI 上運行 JavaFX。 Gluon 通過幫助用戶通過插件部署 JavaFX 插件來進一步擴展支持。 看看:
如果您想了解更多關於嵌入式 JavaFX 的信息,這些是一些有用的鏈接:
由於某些原因,上述鏈接不起作用,但我可以從https://bitbucket.org/javafxports/arm/downloads/ [ dead ] 下載,然后解壓縮文件夾並復制
armv6hf-sdk/rt/lib/ext/**jfxrt.jar** --> jre/lib/ext/
armv6hf-sdk/rt/lib/arm/***** --> jre/lib/arm/
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/
重新啟動 Raspberry Pi 和 FX 應用程序工作正常
您還可以從 Gluon 下載預構建的二進制文件。
http://gluonhq.com/gluon-supports-javafx-embedded-binary-builds-now-available/
是的,您可以在 Raspberry Pi 上運行 JavaFX,但默認情況下某些類庫將無法運行,例如 Media。 目前我仍在嘗試使用這個媒體類庫來處理樹莓派
這個問題已經有點老了,但截至今天,還可以從 Bellsoft 下載並安裝最新的 JDK,其中還包括最新的 JavaFX。 https://www.bell-sw.com/pages/java-11.0.2/
如果有人仍然到達這里,我想指出我寫的一篇文章並演示了這一點: https : //blogs.oracle.com/javamagazine/getting-started-with-javafx-on-raspberry-pi 。 正如 mipa 回答的那樣,BellSoft LibericaJDK 確實是一個完美的 JavaJDK,可以在 Raspberry Pi 上與 JavaFX 一起使用。
是的,您可以使用 JavaFx。
這是一個在 Raspberry PI 上啟用 javafx 的腳本(在 raspbian 上測試)
#!/bin/bash
# install javafx on raspberry PI
# WF 2019-01-13
src=/usr/local/src
ext=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/ext
javafx=armv6hf-sdk
#ansi colors
#http://www.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
blue='\033[0;34m'
red='\033[0;31m'
green='\033[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\033[0m'
#
# a colored message
# params:
# 1: l_color - the color of the message
# 2: l_msg - the message to display
#
color_msg() {
local l_color="$1"
local l_msg="$2"
echo -e "${l_color}$l_msg${endColor}"
}
or
#
# show the given error message on stderr and exit
#
# params:
# 1: l_msg - the error message to display
#
error() {
local l_msg="$1"
# use ansi red for error
color_msg $red "Error:" 1>&2
color_msg $red "\t$l_msg" 1>&2
exit 1
}
#
# error
#
# show the given error message on stderr and exit
#
# params:
# 1: l_msg - the error message to display
#
error() {
local l_msg="$1"
# use ansi red for error
color_msg $red "Error:" 1>&2
color_msg $red "\t$l_msg" 1>&2
exit 1
}
color_msg $blue "Trying to install javafx"
if [ ! -d $ext ]
then
error "directory $ext does not exists - was expecting a java installation"
fi
if [ ! -d $src ]
then
error "directory $src is missing - was expecting it"
fi
cd $src
if [ ! -f $javafx.zip ]
then
color_msg $blue "downloading $javafx.zip"
sudo curl -L https://gluonhq.com/download/javafx-embedded-sdk/ -o $javafx.zip
else
color_msg $green "$javafx.zip already downloaded"
fi
if [ ! -d $javafx ]
then
color_msg $blue "extracting" $javafx.zip
sudo unzip $javafx.zip
else
color_msg $green "$javafx already extracted"
fi
cd $ext
color_msg $blue "creating symlinks"
for path in rt/lib/arm rt/lib/ext/jfxrt.jar lib/javafx-mx.jar lib7JFX rt/lib/jfxswt.jar
do
from=$src/$javafx/$path
b=$(basename $from)
if [ -L $b ]
then
color_msg $green "symbolic link $b already exists"
else
sudo ln -s $src/$javafx/$path .
fi
done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.