Thursday, December 5, 2013

Install JDK8 and run JavaFX on Raspberry Pi

Outdate: As JDK is included in Raspbian now, this post is NOT valid.

Hello Raspberry Pi have a series of posts introducing how to Install JDK8 and run JavaFX on Raspberry Pi.

JavaFX on Raspberry Pi
JavaFX application on Raspberry Pi

1 comment:

  1. JavaFX FXML simple app on PI3 - cant get it to work

    Raspberry PI3 + with HDMI screen :-
    format sd card , write Raspbain Jessie Lite image to class 10 32 GB Micro SD card
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install raspberrypi-bootloader –reinstall
    Install pango library for Fonts
    Sudo apt-get install libpango-1.0-0:armhf libpangoft2-1.0-0:armhf
    Sudo apt-get install libpango1.0-0:armhf
    sudo apt-get install libgtk2.0-0
    sudo raspi-config -> Memory split = 256 + Enabled SSH
    download Linux ARM 32 Hard Float ABI
    Copy Hard_float_32_Java_for_Linux_ARM_V6/7 to /home/pi via filezilla
    sudo tar zxvf FileName.gz -C /opt
    JavaFX Embedded SDK 8.60.8 armv6 hard float
    Copy files as under
    armv6hfsdk/rt/lib/ext/jfxrt.jar -> jre/lib/ext/
    armv6hfsdk/rt/lib/arm/* -> jre/lib/arm/
    armv6hfsdk/rt/lib/ -> jre/lib/
    armv6hfsdk/rt/lib/ -> jre/lib/
    armv6hfsdk/rt/lib/jfxswt.jar -> jre/lib/
    sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 1
    sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 1
    sudo update-alternatives --config javac
    sudo update-alternatives --config java
    sudo nano .bashrc
    export JAVA_HOME=/opt/jdk1.8.0_121
    export PATH=$JAVA_HOME/bin:$PATH
    setterm -blank 0 <- prevent screen going blank
    Now java -version gives :-
    java version 1.8.0_121
    java SE Environment ......
    Java Hotspot ......

    sudo nano /etc/kbd/config
    change following to 0 BLANK_TIME = 0 POWERDOWN_TIME = 0

    sudo nano /boot/config.txt
    Also tried my small HDMI screen resolution = 800 x 480

    My Windows PC Setup :-
    Widows 7 PC with JDK1.8.0_121
    Netbeans 8.0.2 - Remote Java SE Platform - Remote JRE Path = /opt/jdk1.8.0_121
    Exec sufix = sudo --------- Test Platform = Success
    Created a JavaFX FXML application using scene builder 1.1 named hi.jar
    Application runs fine on windows machine
    VP Option => JAVAFX_DEBUG=1 -Djavafx.platform=eglfb -Dglass.platform=Monocle -cp
    -Dmonocle.screen.fb=/dev/fb0 /dev/fb0 = HDMI frame Buffer
    -Dprism.verbose=true -Dprism.debug=true -Djavafx.verbose=true -Djavafx.debug=true

    but on my system ls -lar /dev/fb* => /dev/fb0 = HDMI Frame Buffer
    I tried different VM option conbinations and get following prominant errors :-
    (1)Unable to load font (even though i have pango library installed and /usr/share/fonts has many .ttf files)
    (2) not able to find or load class ( i am sure it find Main method but fails to load it)
    (3) No setting found for javafx.platform=eglfb ( i expect jvafx to use /dev/fb0 HDMI frame buffer ,
    also looked into file but could not draw any conclusion)

    Please drop me few words of advice