Configuring the Raspberry Pi as an Oracle Java ME Embedded Development
Platform
Overview
Purpose
This tutorial covers how to configure a Raspberry Pi as a
development platform for the Oracle Java ME Embedded 8 platform.
Time to Complete
Approximately 1 hour
Introduction
Intelligent devices are becoming an ever more important and
ubiquitous part of our everyday lives. Mobile phones represented
the first wave of smaller personal computers. And now, as the
price of electronics and processing power continues to fall, there
is an intersection between sensors and other electromechanical
devices and computers that live on the edge of the Internet: close
to the source of the data, processing the data locally and sending
just what is required to other computers to consume. This wave of
machine-to-machine (M2M) technology, or more broadly, the Internet
of Things (IoT), is rapidly shaping the future of computing.
Oracle Java Platform, Micro Edition (Java ME) provides Java
developers with a direct path to this new market space by using
their existing knowledge and skills.
In this tutorial, you prepare a Raspberry Pi to run Java ME
Embedded 8, the released version of Java ME Embedded. The
Raspberry Pi is a computer that is about the size of a deck of
cards, yet it is capable of running a Linux distribution on its
ARM 11 processor. The Raspberry Pi also supports USB, Ethernet,
audio, HDMI, and RCA video output. But most importantly, the
Raspberry Pi provides a 26-pin header that connects the computer
to the outside world, through general-purpose input/output (GPIO)
pins that can drive LEDs, read switches and other electronic
signals, and connect to a wealth of inter-integrated circuit (I2C)
devices, universal asynchronous receiver/transmitter (UART)
devices, and more.
Hardware and Software Requirements
The following is a list of hardware and software requirements:
Windows 7 desktop or laptop computer (The Java ME SDK runs
only on Windows platforms.)
Raspberry Pi Model B Revision 2, power supply, Ethernet cable
USB
to TTL Serial Cable (Alternatively, use a USB keyboard and
mouse and an HDMI cable and monitor.)
Install Java JDK 8, Java ME SDK 8, NetBeans IDE, and plugins
for Java ME SDK. See this supporting video.
Download and install the following software:
SD Formatter tool
SHA-1 checksum verifier
Win32DiskImager
PuTTY client
PSFTP client
Download the Oracle Java ME Embedded 8 Raspberry Pi binary zip
file to the C:\Temp directory.
Creating a Bootable Image for the Raspberry Pi
In order to boot, the Raspberry Pi requires a bootable Linux
image on an SD memory card. There is no hard drive for the
computer. Instead, the 4 GB card stores the image that the
computer runs when it is powered on. This SD memory card also acts
as the storage for other applications that are loaded onto the
card.
Formatting the SD Memory Card with the SD Formatter Tool
Insert the SD memory card into your computer or connect
it to your computer by using an SD card peripheral.
If you used a USB SD card reader, remove the SD card
from the reader.
If you used a micro or mini SD card, remove it from
the reader and reinsert it into a full-sized SD adapter.
You are now ready to boot the Raspberry Pi and install the
Java ME Embedded 8 binary for Pi.
Setting Up the Raspberry Pi as a Headless Embedded Device
To set up the Raspberry Pi as a headless embedded device, you
configure Raspbian to allow SSH connections by using a USB/TTY
cable or by using a USB keyboard and an HDMI monitor. To ensure
that the Raspberry Pi always has the same IP address, you
configure the Raspberry Pi to use a static IP address.
Note: If you want to connect your Raspberry Pi
to your network by using both wireless (WLAN) and wired (ETH0)
options, choose a different fixed IP address for each connection
type. Do not use the same IP address.
Option 1: Configuring SSH by Using a USB/TTY Cable
Important: You must install the PL2303HX.A
drivers before you plug the USB cable into your PC.
Connect the Ethernet cable to the Raspberry Pi and to
your network.
Plug the USB end of the cable into your PC.
Note: The USB cable will power the
Raspberry Pi. Do not plug in the
micro-USB power cable at the same time. The Raspberry Pi
should only be powered by one source at a time.
Open an Explorer window, right-click Computer
and select Properties.
Configuring the Raspberry Pi with a Fixed IP Address by Using a
Wired or Wireless Network
To ensure that the Raspberry Pi always has the same IP address,
you configure the Raspberry Pi to use a static IP address. You may
choose to set your Raspberry Pi by using a wired or wireless
network.
Note: If you want to connect your Raspberry Pi
to your network by using both wired (ETH0) and wireless (WLAN)
options, choose a different fixed IP address for each connection
type. Do not use the same IP address.
Option 1: Setting Up the Raspberry Pi to Use a Fixed Wired IP
Address
In a separate command prompt window, enter ipconfig
to display the netmask and default gateway for your
network.
Note: If you are using a wireless
connection, the information appears under the Wireless LAN
adapter heading.
In a PuTTY window, enter sudo nano
/etc/network/interfaces and then perform the
following steps:
Comment out the iface eth0 inet dhcp line
by placing a # symbol at the beginning of the line.
Below that, add the iface eth0 inet static
line.
Use your network settings to add the IP, network,
netmask, broadcast, and gateway addresses. For example: address 192.168.1.105
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Use your network settings to add the IP address,
network mask, and gateway address. For example: address 192.168.1.105
netmask 255.255.255.0
gateway 192.168.1.1
Add the network SSID and passkey for your network in
double quotation marks. For example: wpa-ssid "mynetwork"
wpa-psk "cants@y"
The Raspberry Pi supports only two USB connections. To
use the USB Wifi Module, unplug the USB mouse, USB
keyboard, and Ethernet cable, and then plug in the USB
Wifi module.
Installing the Java ME Embedded 8.1 Early Access Binary on the
Raspberry Pi
To install the Java ME 8.1 EA Embedded binary on the
Raspberry Pi, you transfer the Raspberry Pi binary zip file from
your desktop to the Pi over the SSH connection. Next, you unzip
the file into a new directory.
Restarting the PuTTY Connection
To reconnect to the Raspberry Pi, right-click in the
header of the PuTTY window and select Restart
Session.
To test the connection between NetBeans and the Raspberry Pi, you
write a small program to test the IMlet lifecycle methods (startApp
and destroyApp). Next, you deploy the IMlet to the
Raspberry Pi through the EmbeddedExternalDevice1 emulator and
control the IMlet application by using the emulator.
In NetBeans 8.0, select File > New Project
to create an IMlet project in NetBeans.
In the PuTTY window that is connected to the Raspberry Pi, a
message indicates that the console output is written to the
window where the AMS was started.