java JavaFX 可以在树莓派上使用吗
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36961054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can JavaFX be used on Raspberry Pi
提问by Ahmed
I want to write program for Raspberry Pi using JavaFX but it appears that Java SDK 8 on my Raspberry Pi does not have JavaFX support.
我想使用 JavaFX 为 Raspberry Pi 编写程序,但似乎我的 Raspberry Pi 上的 Java SDK 8 不支持 JavaFX。
So my question is whether JavaFX is supported on Raspberry Pi 2/3
? If yes, why does JDK not have JavaFX libraries on the platform ? Is there a way to support it or worth writing JavaFX application on Raspberry PI ?
所以我的问题是是否支持 JavaFX Raspberry Pi 2/3
?如果是,为什么 JDK 平台上没有 JavaFX 库?有没有办法支持它或值得在 Raspberry PI 上编写 JavaFX 应用程序?
Java version in use is 1.8.0_65
.
使用的 Java 版本是1.8.0_65
.
回答by ItachiUchiha
If you are using Oracle JDK for ARM 8u33 / Oracle Java SE Embedded 8u33
or later, you will not find JavaFX bundled in the JDK. Oracle removed JavaFX Embedded from the ARM bundle starting from 8u33. For more information have a look at this thread from the OpenJFX mailing list.
如果您正在使用Oracle JDK for ARM 8u33 / Oracle Java SE Embedded 8u33
或更高版本,您将找不到捆绑在 JDK 中的 JavaFX。从 8u33 开始,Oracle 从 ARM 捆绑包中删除了 JavaFX Embedded。有关更多信息,请查看OpenJFX 邮件列表中的此线程。
So, can we still use JavaFX on Raspberry PI?
那么,我们还可以在 Raspberry PI 上使用 JavaFX 吗?
Well, of course you can.Here are a few ways you can still run JavaFX on embedded devices :
嗯,当然可以。以下是您仍然可以在嵌入式设备上运行 JavaFX 的几种方法:
Your best shot is to install embedded SDK, provied by Gluon, which includes
jfxrt.jar
for ARM. You can copy the jar into the JDK and have JavaFX running on Raspberry PI. Gluon further extends the support by helping users deploy there JavaFX plugin via plugin. Have a look at :- You can use a previous version of Oracle JDK which bundles JavaFX with it.
- You can also build the OpenJFX and add it to your JDK (not an easy way).
你最好的拍摄是安装嵌入SDK,通过provied胶子,其中包括
jfxrt.jar
了ARM。您可以将 jar 复制到 JDK 中,并在 Raspberry PI 上运行 JavaFX。Gluon 通过帮助用户通过插件部署 JavaFX 插件来进一步扩展支持。看一下 :- 您可以使用与 JavaFX 捆绑在一起的先前版本的 Oracle JDK。
- 您还可以构建 OpenJFX 并将其添加到您的 JDK(不是一种简单的方法)。
If you want to know more about JavaFX on embedded, these are some useful links :
如果您想了解更多关于嵌入式 JavaFX 的信息,这些是一些有用的链接:
- Cross Building for ARM Hard Float
- Where's JavaFX in recent Java 8u33 for the ARM ?
- For JavaFX 11, one can read JavaFX 11 early access on embedded.
- ARM 硬浮点的交叉构建
- 最近用于 ARM 的 Java 8u33 中的 JavaFX 在哪里?
- 对于 JavaFX 11,可以在嵌入式.
回答by Gopi Krishna
for some reasons the above links are not working but I was able to download from https://bitbucket.org/javafxports/arm/downloads/then unzip the folder and copy
由于某些原因,上述链接不起作用,但我可以从https://bitbucket.org/javafxports/arm/downloads/下载, 然后解压缩文件夹并复制
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/
Restart Raspberry Pi and FX Application worked fine
重启 Raspberry Pi 和 FX 应用程序工作正常
回答by mipa
You can also download pre-built binaries from Gluon.
您还可以从 Gluon 下载预构建的二进制文件。
http://gluonhq.com/gluon-supports-javafx-embedded-binary-builds-now-available/
http://gluonhq.com/gluon-supports-javafx-embedded-binary-builds-now-available/
回答by Alex
Yes, you can run JavaFX on Raspberry Pi but some of class library will not work by default, as example Media. Currently I'm still trying to use this Media class library to work on raspberry Pi
是的,您可以在 Raspberry Pi 上运行 JavaFX,但默认情况下某些类库将无法运行,例如 Media。目前我仍在尝试使用这个媒体类库来处理树莓派
回答by Wolfgang Fahl
Yes you can use JavaFx.
是的,您可以使用 JavaFx。
Here is a script to enable javafx on Raspberry PI (tested on raspbian stretch)
这是一个在 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='3[0;34m'
red='3[0;31m'
green='3[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='3[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=""
local l_msg=""
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=""
# 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=""
# 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
回答by mipa
The question is already a bit old but as of today one could also download and install the latest JDK from Bellsoft which also includes the latest JavaFX. https://www.bell-sw.com/pages/java-11.0.2/
这个问题已经有点老了,但截至今天,还可以从 Bellsoft 下载并安装最新的 JDK,其中还包括最新的 JavaFX。 https://www.bell-sw.com/pages/java-11.0.2/