One of the "cool" features of
Java ME Embedded 8 is the Device I/O (DIO) API. With
you can write Java code to take advantage of the GPIO header on the Raspberry Pi,
and connect LED's, switches,
SPI devices, and serial devices that use a
This opens up the world of the Internet of Things to Java developers, and for less than $40 US!
Java SE, both 7 and 8 are also available for the
Raspberry Pi (ARM 6 architecture),
and if you want to explore Java SE Embedded, and play with profiles, you can do that too.
But what about
Java EE and Web Services?
How do I access devices using servlets and web services?
The answer is by combining two technologies.
Recently, the Device I/O API has been under development as an
Open JDK project - creating a standalone way to access the
GPIO header using exactly
the same API that makes
Java ME Embedded so special.
This allows developers to write
DIO code outside of a Java ME Embedded VM.
OpenJDK Device I/O is a third-party library which leverages standard Java ME Device I/O APIs to Java SE.
To learn more:
1 Install JDK 1.8
Ensure JDK 1.8 is installed
$ java -version
If not installed you can install it by doing:
$ sudo apt-get update $ sudo apt-get install oracle-java8-jdk
2 Install JDK IO
Next, download the JDK DIO developer code. This library has device providers for JDK Device I/O v1.0 (in Mercurial master repository) and v1.1 Mercurial (in dev repository).
$ sudo apt-get -y install mercurial
$ sudo apt-get install zip unzip
Create directory deviceio
$ mkdir deviceio $ cd deviceio
dio1.0 (master repository) or 1.1 (dev repository)Copy
$ hg clone http://hg.openjdk.java.net/dio/master/
deviceiocloned directory masterCopy
$ cd master $ ls -l
$ ls /usr/lib/jvm/
JAVA_HOMEto point the installed javaCopy
$ export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt $ export PI_TOOLS=/usr $ make osgi
Now copy the libraries in
$ cp build/deviceio/lib/ext/dio.jar dio-1.0.jar $ sudo cp build/deviceio/lib/ext/dio.jar $JAVA_HOME/jre/lib/ext/. $ sudo cp build/deviceio/lib/arm/libdio.so $JAVA_HOME/jre/lib/arm/.
diolibrary to a workstation if you are using cross development. In the example we transfer from a pi located at address 192.168.1.47 to our local workstation:Copy
$ scp firstname.lastname@example.org:/home/pi/dio/master/dio-1.0.jar .