SpanglefishDMS Consulting | sitemap | log in
This is a free Spanglefish 1 website.

Raspberry PI JavaFX

The Project

The idea behind this project was to take the examples of JavaFX found in a Tutorial by Alla Redko, a Technical Writer for Oracle, and make them work on the Raspberry PI.

The Examples

The examples were downloaded from Alla Redko and installed into Eclipse on a PC. All the example ran fine on the PC so the class files were transfered to the PI. The PI is running Java 8 and I quickly discovered I needed a path to the JavaFX jar file - jfxrt.jar. I also discovered, from the PI forum, I needed a java diagnostic flag set - -Djavafx.platform=eglfb. The examples still would not work. Talking to the forum, a very helpful member (from Oracle) helped me with the final problems. You need a directly attached mouse (not a KVM) and if you have a ID other than root or pi, that ID must be a member of input group - usermod -a -G input newid.
The first example failed because the file paths all used the windows slash. The examples were changed to use a simple static class that loads the appropiate slash.
The examples started to work but JavaFX running on the PI does not have a frame round the window. The only way to close the example was control C but the currect version of JavaFX traps control C.

To get round the termination problem, PIFrame was written. It is still very basic but does have a close window X in the top right and it displays the window title.

Installing Java

The first file to install is a Java Run Time Environment (jre). If you want to compile java on the PI you will need to find a Java JDK.
I used Eclipse on a PC to edit the code and tested the routines on both a PC and the PI.
Note - You need Java 8 and that runs under Raspbian. My system uses  2012-12-16-wheezy-raspbian.img and runs Java 8
jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
Watch out for later version that will fix the bugs.

Installing the JavaFX files

The files that need to be installed can be found on SourceForge.
sourceforge.net/projects/rpjavagfx/files/
Start by downloading -
javafx-examples1.tar.gz - the original files with slash changes
javafxpi-examples1.tar.gz - files modified to use PIFrame
javafx-dms-library1.tar.gz - library files
javafx-script1.tar.gz - script file to run examples
Transfer the files to the PI to your home directory. (/home/pi)
Run the following for each tar.gz file - tar -xvzf filename
This will create a java folder containing javafx (original examples) and javafxpi (modified examples).
The other files on SourceForge contain the source of the Java examples.

Running the Examples

cd into the java directory and run the following -
./java javafxpi.ButtonSamplePI
There are quite a few examples, most of which run. A couple fail - "can't find webkit build" and two others need some tweeking.
The following is a list of the examples - the tutorial by Alla Redko explains what they do.


ButtonSamplePI
CheckboxSamplePI
ChoiceBoxSamplePI
ColorPickerSamplePI
ComboBoxSamplePI
HTMLEditorSamplePI
HyperlinkSamplePI
HyperlinkWebViewSamplePI
LabelSamplePI
ListViewSamplePI
MenuSamplePI
PaginationSamplePI
PasswordFieldSamplePI
ProgressSamplePI
RadioButtonSamplePI
ScrollBarSamplePI
ScrollPaneSamplePI
SeparatorSamplePI
SliderSamplePI
TableViewSamplePI
TextFieldSamplePI
TitledPaneSamplePI
ToggleButtonSamplePI
TooltipSamplePI
TreeViewSamplePI
TSESPI

Support

You can contact me via the Raspberry PI forum

Search for Java, JNI, OpenGL

Links

JavaFX Tutorial by Alla Redko

The Raspberry PI Foundation

Java-Embedded-Raspberry-Pi

Interests and links

 

WikanikoWork from Home
sitemap | cookie policy | privacy policy