Search by Tags

Java Virtual Machine

 

Article updated at 13 Jul 2021
Compare with Revision




Introduction

Java has some inherent benefits such as portability, application isolation, extensive standard libraries, among others. It also has some limitations including JVM overhead. Java applications on embedded devices commonly rely on Java Native Access (JNA) and Java Native Interface (JNI) to incorporate C libraries, notably low-level HW/OS interfaces, which may impact application portability.

Linux

Toradex has tested the following Java Virtual Machines with our Linux images:

Installing Java

OpenJDK

OpenJDK may be added as a layer to a custom Yocto build for standalone compilation or inclusion into a custom-built Linux image. For generic information on how to build a Yocto image, read Build a Reference Image for Yocto Project and then add the Java layer according to the instructions below:

Define the layer version and add the repository meta data:

cd
cd oe-core/layers

# repository version known to work with V2.0 images
META_JAVA=f5f49c8fd63d6d38938972841759006c69afcc15

# repository version known to work with V2.1 images
META_JAVA=14d6ad1608c66b8970d4052dce4cd1fc64fb6ea2

# repository version known to work with V2.4 images
META_JAVA=4aea395deed99b2725b56d4a86fb4712fcf504d7

# repository version known to work with V2.5 images
META_JAVA=0d7ba0ff39a332b0f93c4958370b2c7db9ea0e30

# repository version known to work with V2.6 images
META_JAVA=1d820a778c0aa5d1d8bbff9949e77c32a08c8a7b

# repository version known to work with V2.7 images
META_JAVA=65bd3d6eaa6ae4e06f1c04efb493f448cf6d619b 

# repository version known to work with V2.8 images
META_JAVA=fbe0b0eb30d93f5fa2101fb015f20c1dc118b4a6

git clone --no-checkout http://git.yoctoproject.org/git/meta-java
cd meta-java; git checkout -b mywork $META_JAVA; cd ..

Add the layer to build/conf/bblayers.conf

--- build/conf/bblayers.conf~   2012-10-19 17:39:36.000000000 +0200
+++ build/conf/bblayers.conf    2013-04-22 18:31:58.278660259 +0200
@@ -17,6 +17,7 @@
   ${TOPDIR}/../layers/meta-openembedded/meta-multimedia \
   ${TOPDIR}/../layers/oe-tworaz/meta-lxde \
   ${TOPDIR}/../layers/meta-browser \
+  ${TOPDIR}/../layers/meta-java \
 " 

 # These layers hold machine specific content, aka Board Support Packages

Note that this will build OpenJDK without xawt, the Abstract Window Toolkit giving one framework for a graphical user interface. In order to build with xawt you will have to patch recipes-core/openjdk/openjdk-7*/icedtea-jdk-nio-use-host-cc.patch.

--- a/recipes-core/openjdk/openjdk-7-75b13/icedtea-jdk-nio-use-host-cc.patch
+++ b/recipes-core/openjdk/openjdk-7-75b13/icedtea-jdk-nio-use-host-cc.patch
@@ -49,26 +49,3 @@ Index: openjdk/jdk/make/java/nio/Makefile
 -endif

  .PHONY: sources
-Index: openjdk/jdk/make/sun/Makefile
-===================================================================
---- openjdk/jdk/make/sun/Makefile      2013-07-25 09:10:09.000000000 -0700
-+++ openjdk/jdk/make/sun/Makefile      2013-10-01 21:32:01.625839149 -0700
-@@ -55,7 +55,7 @@
-     endif
-   endif
-   HEADLESS_SUBDIR = headless
--  XAWT_SUBDIR     = xawt gtk
-+  XAWT_SUBDIR     = 
- endif
- 
- ifeq ($(PLATFORM), macosx)
-@@ -87,7 +87,7 @@
- endif
- SUBDIRS_desktop    = audio $(RENDER_SUBDIR) image \
-                      $(LWAWT_PRE_SUBDIR) $(DISPLAY_LIBS) $(DGA_SUBDIR) $(LWAWT_SUBDIR) \
--                     jawt font jpeg cmm $(DISPLAY_TOOLS) beans 
-+                     font jpeg cmm $(DISPLAY_TOOLS) beans
- SUBDIRS_management = management
- SUBDIRS_misc       = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
- SUBDIRS_tools      = native2ascii serialver tools jconsole
- 
\ No newline at end of file

To use the layer either add openjdk-7-jre and openjdk-7-demo packages to your image recipe or build the openjdk-7 recipe and install the openjdk-7-jre...ipk and openjdk-7-demo...ipk packages and their dependencies.

Run a demo application on the module

java -jar /usr/lib/jvm/java-7-openjdk/demo/jfc/Font2DTest/Font2DTest.jar

Oracle JVM

Oracle JDKs/JREs are available for download from Oracle's website. Be sure to read the software license for restriction details.

Our internal benchmarks show that the Oracle ARM JVM out-performs the OpenJDK ARM JVM in most cases.

Windows Embedded Compact

On Windows Embedded Compact 7 we tested a beta version of Oracle SE7. If you are interested in a demo please contact our support

We also tested these older Java VMs:

The following JVMs have not been tested by us: