Installing JavaFX Support in the Raspberry Pi

It looks like Java 8 with Swing runs fine on the Raspberry Pi, even the least powerful version of the RPi:
Raspberry Pi Zero.

As I found out jfxswt.jar required to run JavaFX is not included in the JDK normally any more.

How would I find the folder to place it so that JavaFX can be run on the RPi?

( I got it downloaded as part of Gluon)

If this file is included can I also compile JavaFX on the RPi or just run it?
(Does it need to be compiled on a separate desktop computer?)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Maybe its better to install OpenJDK implementation of JavafX...get it here...
Be careful - it's not just that jar that it contains. It contains others, such as jfxrt.jar, which is probably the main one, AND native libraries
AttilaBAuthor Commented:
My concern though is, that if I install  OpenJDK what will happen to the current Oracle JDK 8?

How can I choose which JDK I want to use for compiling or running?

Can I only have one installed at a time?
It's more than a bit unsatisfactory to guess, but this is what i'd do in the absence of  documentation

a. Unzip the Gluon archive to $HOME
b. Ensure that the directory containing native libraries is on $LD_LIBRARY_PATH
c. Put a symlink to the jars in one of the non-jdk paths in System property java.ext.dirs

An example of c.:
goose@t410:/tmp$ ll /usr/java/packages/lib/ext
total 16
drwxr-xr-x 2 root root 4096 Jan 31 15:59 .
drwxr-xr-x 3 root root 4096 May 20  2016 ..
lrwxrwxrwx 1 root root  104 May 20  2016 proteanit-1.0-1.0-SNAPSHOT.jar -> /tmp/h/home/goose/.m2/repository/net/proteanit/proteanit-1.0/1.0-SNAPSHOT/proteanit-1.0-1.0-SNAPSHOT.jar
lrwxrwxrwx 1 root root  123 Jan 31 15:59 technojeeves-jlib-1.0-1.0-SNAPSHOT.jar -> /tmp/h/home/goose/.m2/repository/com/technojeeves/technojeeves-jlib-1.0/1.0-SNAPSHOT/technojeeves-jlib-1.0-1.0-SNAPSHOT.jar

Open in new window

AttilaBAuthor Commented:
Will try it when I get home today and let you know.
AttilaBAuthor Commented:
I managed to install OpenJDK and being able to select between Oracle and OpenJDK, with both installed:

sudo apt-get install openjdk-8-jdk

sudo update-alternatives --config java

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-8-openjdk-armhf/jre/bin/java          1063      auto mode
* 1            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java          1063      manual mode
  2            /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java   318       manual mode

Press enter to keep the current choice[*], or type selection number: 2

Open in new window

I ran the same Java Swing apps with both JDKs, and ran fine but significantly slower
with OpenJDK.  (Jar and other libraries loading in 50% longer with OpenJDK 1.8, running the same code 4x slower the same code ran
with Oracle 1.8).)

Neither of them is able to run JavaFX 'out of the box' of course.

I  managed to find the following instructions, that is specific to running the JFX on the raspberry pi:

So, I downloaded the zip, and extracted to:  /home/pi/armv6hf-sdk/
Location of Unzipped folder
I cannot get it going, according to the instructions:
(I don't even quite understand what it is supposed to do....)
pi@raspberrypi:~ $ -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib/ext
bash: -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib/ext: No such file or directory
pi@raspberrypi:~ $ -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib
bash: -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib: No such file or directory
pi@raspberrypi:~ $ 

Open in new window

Do you know what it all means?
pi@raspberrypi:~ $ -Djava.ext.dirs=/home/pi/armv6hf-sdk/rt/lib/ext

Open in new window

Is not going to do anything on its own. But i've already given you instructions ..?
John TsioumprisSoftware & Systems EngineerCommented:
I am thinking that something is wrong....i guess the best solution is to start from scratch....just erase your SD card ...reload RPI OS and follow the tutorials step by step...even download the exact versions....later on you can upgrade....
Last but not least....sorry for that comment but JavaFX is pretty much abandoned and i hope you have a solid reason why you want to install on your PI....if its just for fun its better to find something else....if you don't believe me just take a look at the jobs posting in your area/city/country/ will see that are less than few...
..sorry for that comment but JavaFX is pretty much abandoned and i hope you have a solid reason why you want to install on your PI....if its just for fun its better to find something else....if you don't believe me just take a look at the jobs posting in your area
I don't know why you think that. If the jobs thing is the only reason (and i take you at your word) then i'm skeptical that there is always a strong correlation between the health of a technology and jobs in it. You could say that Java on the desktop struggles in general, and if you told me that there are few jobs available designing Swing guis,  i wouldn't be at all surprised. But that's a different point.
AttilaBAuthor Commented:
John, well JavaFX may be dead-ended on the Raspberry Pi because Oracle doesn't want to continue with it on the ARM machines now, but I think in general it is a sensible way to make  applications, as far as a rich client framework that provides a modular application architecture. It has been around for quite a while, along with the idea of splitting up applications for a GUI structure, applications styling and functionality. It is way easier to make something that 'looks really cool', and also the hole idea of its structure I think promotes maintainability of code.
Compared to Swing.

If it runs at comparable speed with the way more simplistic Java Swing on a certain machine, I would certainly want to use it instead. I wanted to do some cool projects with the Raspberry Pi, especially the Zero version if possible, because it is so tiny and can be built into almost anything.

I think maybe certain versions of JavaFX may be dead for certain platforms, for the long term, or for now, but the whole idea of the way to make apps the way JavaFX does it is certainly alive, and probably will be in the future.
I think.

CEHJ, yes you have given me instructions as:

b. Ensure that the directory containing native libraries is on $LD_LIBRARY_PATH
c. Put a symlink to the jars in one of the non-jdk paths in System property java.ext.dirs
The problem is though that I am having trouble understanding these 2 lines as of what these mean and how I would do this in practicality.

Can you give more detail?
Sorry - i'm taken up with Live at the moment
AttilaBAuthor Commented:
No problem. I can only try this in 8-10 hours from now, when I get home. If you give me details some time on how to do this, that will be perfect. Whenever you have time.
AttilaBAuthor Commented:
Hi CEHJ, so do you have time now to tell me more details about your suggestions?

(More step by step instruction, so that I understand this better)

AttilaBAuthor Commented:
I think the .bashrc file needs to be set up somehow. I just don't know how.
AttilaBAuthor Commented:
Well, since nobody is talking to me, I decided to try a new approach:

The idea here is this you are only running it on the Pi. I always tried to compile it as well.
Also, I will have to use the exact same version installed on the desktop computer.

If this works then I will close the question.
AttilaBAuthor Commented:
Why am I insisting that it should work on the RPi?

See example here:
Yes, there's absolutely no reason to compile it on an underpowered machine, but you can if you want
AttilaBAuthor Commented:
I guess it is just a 'teaser'. It looks like 2-3 years ago it was a no-brainer to run JavaFX on an ARM system. Before Oracle pulled the plug on the ARM support.

It is impossible to get the proper older versions now, to match it up with a desktop SE system.  I give up.

At least I have Java 1.8.0_65 version with Swing running fine on the Raspberry Pi with the Pi4J hardware Java libraries. I can do the project that way. Hell with it!

'God bless' Oracle!!!  :(

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pretty sure it can be done. Just requires a bit of sweat
AttilaBAuthor Commented:
NO solution.

fyi i've just run the above JFX app on my Pi. There are windowing problems though
AttilaBAuthor Commented:
Actually I started to do this project involving 6-7 JFrames myself, using Swing with Regular Java 8. The new packages such as time seem to work fine, and the whole thing is pretty fast. I am quite confident at least this will work out for me. It will be a fairly large program, I will concentrate on the functionality, which is the same, regardless of the GUI.

I may run into some issues making it look nice on the screen. It is pretty bland now with default Swing controls.
I will look into customizing, and may will have some Swing questions to post to EE. You are an expert of that, I know.

Hell with JavaFX on the ARM processor:  too experimental, and no longer supported, anyhow.

What are the Windowing problems you have with JavaFX, if I may ask?
Running without window decorations and with udev errors
AttilaBAuthor Commented:
That really sucks. If you can't make fancy screens with it, what good is it? I am glad I am staying away from it.
Thanks for the info.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.