Reputation: 15069
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.
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 ?
Java version in use is 1.8.0_65
.
Upvotes: 17
Views: 21072
Reputation: 119
for some reasons the above links are not working but I was able to download from https://bitbucket.org/javafxports/arm/downloads/ [dead] then unzip the folder and copy
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
Upvotes: 4
Reputation: 6687
If someone still arrives here, I would like to point out an article I wrote and demonstrates exactly this: https://blogs.oracle.com/javamagazine/getting-started-with-javafx-on-raspberry-pi. As mipa answered, BellSoft LibericaJDK is indeed a perfect JavaJDK to work with JavaFX on the Raspberry Pi.
Upvotes: 1
Reputation: 10640
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/
Upvotes: 1
Reputation: 15614
Yes you can use JavaFx.
Here is a script to enable javafx on Raspberry PI (tested on raspbian stretch)
#!/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
Upvotes: 0
Reputation: 36792
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.
So, can we still use JavaFX on Raspberry PI?
Well, of course you can. Here are a few ways you can still run JavaFX on embedded devices :
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 :
If you want to know more about JavaFX on embedded, these are some useful links :
Upvotes: 21
Reputation: 11
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
Upvotes: 1
Reputation: 10640
You can also download pre-built binaries from Gluon.
http://gluonhq.com/gluon-supports-javafx-embedded-binary-builds-now-available/
Upvotes: 1