Link to home
Start Free TrialLog in
Avatar of AttilaB
AttilaB

asked on

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?)
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

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
Avatar of AttilaB
AttilaB

ASKER

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
http://technojeeves.com/index.php/aliasjava1/16-javasystemproperties

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

Avatar of AttilaB

ASKER

Will try it when I get home today and let you know.
Avatar of AttilaB

ASKER

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:
http://stackoverflow.com/questions/28284239/javafx-ensemble-on-raspberry-pi

So, I downloaded the zip, and extracted to:  /home/pi/armv6hf-sdk/
User generated image
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 ..?
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/continent....you 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.
Avatar of AttilaB

ASKER

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
Avatar of AttilaB

ASKER

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.
Avatar of AttilaB

ASKER

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)

Thanks.
Avatar of AttilaB

ASKER

I think the .bashrc file needs to be set up somehow. I just don't know how.
Avatar of AttilaB

ASKER

Well, since nobody is talking to me, I decided to try a new approach:

http://javafx.steveonjava.com/javafx-on-raspberry-pi-3-easy-steps/#download

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.
Avatar of AttilaB

ASKER

Why am I insisting that it should work on the RPi?

See example here:
https://www.youtube.com/watch?v=Rkidpcag1hc
Yes, there's absolutely no reason to compile it on an underpowered machine, but you can if you want
ASKER CERTIFIED SOLUTION
Avatar of AttilaB
AttilaB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pretty sure it can be done. Just requires a bit of sweat
Avatar of AttilaB

ASKER

NO solution.
http://docs.oracle.com/javafx/2/get_started/hello_world.htm

fyi i've just run the above JFX app on my Pi. There are windowing problems though
Avatar of AttilaB

ASKER

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
Avatar of AttilaB

ASKER

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.