Friends of OpenJDK Today

Installing Java and JavaFX on the Raspberry Pi

September 01, 2020

Author(s)

  • Avatar photo
    Frank Delporte

    Frank Delporte (@frankdelporte) is a Java Champion, Java Developer, Technical Writer at Azul, Blogger, Author of "Getting started with Java on Raspberry Pi", and Pi4J Contributor. Frank blogs about his ... Learn more

One of the most read articles on my blog is about the installation of a recent Java on Raspberry Pi (March 13, 2019), so it was time for an update, which is here republished on foojay.

Disclaimer: this article is only valid for Raspberry Pi’s with an ARMv7 or ARMv8 processor. In the Raspberry Pi specifications table on Wikipedia, you get a clear overview of the Pi-types with this processor:

  • Model A+, version 3
  • Model B, version 2, 3 and 4
  • Compute Module, version 3

Raspbian OS with Java 11

In the release notes of Raspbian you can see that the version of 2019-06-20 includes OpenJDK 11:

2019-06-20:
* Based on Debian Buster
* Oracle Java 7 and 8 replaced with OpenJDK 11

So, if we start with a fresh new Raspbian OS, we indeed get this Java version result:

$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-post-Raspbian-5)
OpenJDK Server VM (build 11.0.3+7-post-Raspbian-5, mixed mode)

This means we are already good to start any Java 11 based program!

Liberica JDK to Run JavaFX

As JavaFX is no longer part of the Java JDK, since version 11, running a JavaFX program on the Raspberry Pi will not work out of the box.

Luckily, we can use the Liberica JDK, which is provided by BellSoft. They have a version dedicated for the Raspberry Pi, which includes JavaFX, so you will be able to run a JavaFX application with a simple “java -jar yourapp.jar” start command.

Installing Liberica JDK

We only need the download link from their site to install an alternative Java JDK like this:

$ cd /home/pi
$ wget https://download.bell-sw.com/java/13/bellsoft-jdk13-linux-arm32-vfp-hflt.deb
$ sudo apt-get install ./bellsoft-jdk13-linux-arm32-vfp-hflt.deb
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java

When this is done, we can check the version again and it should look like this:

$ java --version
openjdk version "13-BellSoft" 2019-09-17
OpenJDK Runtime Environment (build 13-BellSoft+33)
OpenJDK Server VM (build 13-BellSoft+33, mixed mode)

On my test-Pi I even keeping different versions of LibericaJDK and switching is very easy with “update-alternatives”.

Install Scripts on GitHub

On Github, in the sources of my book “Getting started with Java on Raspberry Pi”, you can find install scripts for multiple versions of Liberica JDK, which already contain the correct download link for each one:

Topics:

Author(s)

  • Avatar photo
    Frank Delporte

    Frank Delporte (@frankdelporte) is a Java Champion, Java Developer, Technical Writer at Azul, Blogger, Author of "Getting started with Java on Raspberry Pi", and Pi4J Contributor. Frank blogs about his ... Learn more

Comments (0)

Your email address will not be published. Required fields are marked *

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Save my name, email, and website in this browser for the next time I comment.

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard