Last edited one year ago

How to install JAVA JDK

Applicable for STM32MP13x lines, STM32MP15x lines

Warning DB.png Important
The JAVA JDK, subject of this article, is not part of STM32MPU ecosystem releases, for which ST provides some support.
This article only provides, as example, some helper guidelines (tips): you may need to make some adaptations depending on your system setup.

This article has been written taken as example STM32MP157x-DKx Discovery kit More info green.png or STM32MP157x-EV1 Evaluation board More info green.png on top of ecosystem release v2.0.0 , but the recommendations, given below, could be adapted to install JAVA JDK on any other boards with STM32 MPU, populated with any STM32MPU ecosystem releases.

The goal of this page is to describe the OpenJDK installation procedure on your STM32 MPU board and (native) desktop, in a STM32MP1 Distribution Package environment.
It is the "Open Standard Edition Java Development Kit" installation process. According to the OpenstLinux Weston software architecture, XWayland is used for all Java applications based on X11, which means AWT/SWING Java display/graphical applications.
By default the Java Development Kit is installed on the rootfs partition of the target.


1. Prerequisites[edit source]

1.1. Hardware prerequisites[edit source]

  • STM32MP157x-DKx Discovery kit More info green.png or STM32MP157x-EV1 Evaluation board More info green.png
  • a keyboard and a mouse connected to the board

1.2. Software prerequisites[edit source]

The STM32MP1 Distribution Package must be installed on your host. To do this, follow the procedure described in the STM32MP1 Distribution Package#Installing the OpenSTLinux distribution article.

The process has been verified with ecosystem release v2.0.0 of the OpenSTlinux distribution.

Info white.png Information
The Host OS Ubuntu release 18.04 and next is required. See PC prerequisites

2. The yoctoproject meta-java[edit source]

JAVA for Linux-based embedded systems is available as metadata in the Yocto project.

  • Clone the following git repository into [your STM32MP1 Distribution path]/layers
cd [your STM32MP1 Distribution path]/layers
git clone git://git.yoctoproject.org/meta-java

Depending on the Yocto release, select the right branch. (for example, branch dunfell for the ecosystem release v2.0.0 )

Info white.png Information
The last commit tested is cf9604a4789801d9dfb0cb8ca134ff04b42ae161 : openjdk-8: remove -Werror
cd meta-java
git checkout  remotes/origin/dunfell 

You can see the list of available Yocto branches with the following command:

cd meta-java
git branch -a

 master
 remotes/origin/HEAD -> origin/master
 remotes/origin/dora
 remotes/origin/dunfell
 remotes/origin/g0hl1n/jdk14
 remotes/origin/krogoth
 remotes/origin/master
 remotes/origin/master-next
 remotes/origin/morty
 remotes/origin/pyro
 remotes/origin/rocko
 remotes/origin/sumo
 remotes/origin/thud
 remotes/origin/warrior
 remotes/origin/zeus
  • If not already done, set up your build environment
 cd [your STM32MP1 Distribution path]
 source layers/meta-st/scripts/envsetup.sh
(Select for the DISTRO openstlinux-weston and for MACHINE stm32mp1)
  • Add the meta layer in your Yocto environment
 cd [your STM32MP1 Distribution path]/build-openstlinuxweston-stm32mp1
 bitbake-layers add-layer [your STM32MP1 Distribution path]/layers/meta-java
  • Define at least the following variables in your local.conf file
([your STM32MP1 Distribution path]/build-openstlinuxweston-stm32mp1/conf/local.conf)

#Possible provider: cacao-initial-native and jamvm-initial-native
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"

#Possible provider: cacao-native and jamvm-native
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"

#Optional since there is only one provider for now
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"


  • Include in your image the openjdk-8 component
 cd [your STM32MP1 Distribution path]/meta-st/meta-st-openstlinux/recipes-st/images

  • Edit the file st-image-weston.bb and add the following line under CORE_IMAGE_EXTRA_INSTALL
  openjdk-8 \
  openjdk-8-demo \
  • Increase the Rootfs partition size

Update the file ([your STM32MP1 Distribution path]/ layers/meta-st/meta-st-stm32mp/conf/machine/include/st-machine-common-stm32mp.inc)

IMAGE_ROOTFS_MAXSIZE = "819200"
  • Build the image
 cd [your STM32MP1 Distribution path]/build-openstlinuxweston-stm32mp1
 bitbake st-image-weston

3. Compilation and execution of some JAVA demos[edit source]

  • forkjoin benchmark Java application
 cd /usr/lib/jvm/openjdk-8/sample/forkjoin/mergesort
 javac MergeDemo.java
 java MergeDemo 200 100 3 1 1 3
Running with parameters: 200 100 3 1 1 3
Time in milliseconds. Y-axis: number of elements. X-axis parallelism used.
            1    2    3
    200:   10    7    8
    300:   17   12   12
    400:   20   14   14
  Total:   47   33   34
  • SampleTree Java application

Read the README.txt file for details. To execute in a Linux Weston console on the board, with a keyboard and a mouse.

 cd /usr/lib/jvm/openjdk-8/demo/jfc/SampleTree
 java -jar SampleTree.jar

Sampletree.png