How it works...

The java-library class will create a library package with the name lib<package>-java. To add it to a target image, we would use the following:

IMAGE_INSTALL_append = " libjava-helloworld-java" 

The recipe above adds the java2-runtime as a runtime dependency. To select which of the available providers, like OpenJRE 7 or 8, to use, we add the following to either our distro configuration or conf/local.conf:

PREFERRED_PROVIDER_java2-runtime = "openjre-8" 

However, the RPROVIDES in the library recipe will not install OpenJRE into the filesystem; so, we need to add it ourselves to our image recipe or conf/local.conf file with the following:

IMAGE_INSTALL_append = " openjre-8" 

The available JREs do not currently run over the framebuffer or Wayland, so we will use an X11-based graphical image like core-image-sato:

$ cd /opt/yocto/fsl-community-bsp/
$ source setup-environment wandboard-quad
$ bitbake core-image-sato

We can then boot it, log in to the target, and execute the example with OpenJDK by running:

# export DISPLAY=:0
# java -cp /usr/share/java/java-helloworld.jar HelloWorldSwing
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset