1 Installing Oracle Java ME Embedded Software on the Raspberry Pi Board

This chapter describes installing the Oracle Java ME Embedded 8.3 software on the Raspberry Pi board, installing and using the Developer Agent program on the desktop host, configuring the Oracle Java ME Embedded system, and connecting to the Raspberry Pi using a secure shell.

This chapter contains the following topics:

Required Hardware and Software Items

This section describes the hardware and software items that are required for developing on the Raspberry Pi board.

  • Raspberry Pi 2, Raspberry Pi Rev. B or Rev. B+ 512 MB board

  • Oracle Java ME Embedded 8.3 distribution or Oracle Java ME SDK 8.3

    Note:

    You have two options to work with the Raspberry Pi board: with or without using the Java ME SDK. You can use the Java ME SDK to setup your Raspberry Pi device or download the Oracle Java ME Embedded distribution and install it manually.

  • Micro-USB power supply of 0.7 or greater amps, and 5 volts. Note that the power supply must have a micro-USB type B connector, not a regular USB or mini-USB connector.

  • USB keyboard, mouse, and a monitor. If necessary for your monitor, use an HDMI-to-DVI video cable or adapter.

  • SD card of 4 GB or greater. An SD-HC class 10 card is recommended. Do not use a high-speed SD card, because it may be too fast for the Raspberry Pi board.

  • Ethernet cable with an RJ-45 connector, as well as a connection to a network with a DHCP server.

  • A terminal emulator program, such as PuTTY, if you wish to connect to the board using the Application Management System (AMS) interface.

Note:

Oracle Java ME 8.3 supports working with any embedded display with the frame buffer interface such as Adafruit PiTFT 3.5" Touch Screen for Raspberry Pi.

Installing the Raspbian Pi Operating System on the Raspberry Pi Board

To develop applications on the Raspberry Pi board, you must first download and install the Raspbian operating system (based on Debian Wheezy) on the Raspberry Pi board. Note that if you want to use the embedded display, you must download the customized operating system image. For more information, see Preparing Raspberry Pi Board for Working With an Embedded Display.

To install the Raspbian Pi operating system, follow these steps:

  1. Download the Raspbian raw image ZIP file to your desktop from the following site:
  2. Unzip the distribution file, which creates a single disk image (.img) file.
  3. Mount the SD card to the desktop, and use a utility to write the disk image file to the SD card. Note that this is not the same as copying the file to the base-level directory on the SD card. Instead, it is similar to burning a disk image onto a CD-ROM or DVD-ROM. There are a number of utilities that perform this action:
  4. Eject or unmount the SD card from the desktop computer.
  5. Install the SD card in the Raspberry Pi board.

Preparing the Raspberry Pi Board for Work

To prepare the Raspberry Pi board for work, follow these steps:

  1. Connect the RJ-45 network cable, monitor, keyboard, and mouse to your Raspberry Pi board.
  2. Connect power to the Raspberry Pi board. The red light on the Raspberry Pi board should glow, then in a few seconds, the green light should blink. The blinking green light indicates that the Raspberry Pi board is booting Linux.
  3. If the Linux installation was successful, the Raspberry Pi board will start and obtain a DHCP address.
  4. A configuration program (raspi-config) runs, which helps you expand the file system partition on the SD card, configure the keyboard and time zone, reset the default password, and so on. Use the up and down arrow keys to make a menu choice. Use the left or right arrow keys to select OK or Cancel. Press Return to run your choice. Note that the default user name is pi, and the default password is raspberry.
  5. You can perform an update, start the ssh server, and set the graphical desktop to automatically start, then click Finish. At this point, the board should reboot.
  6. Log in if necessary, and if you are using the desktop, start an LXTerminal.
  7. Run the ifconfig command to display the Raspberry Pi IP address. This is necessary so that you can access and control the board remotely. Remember this IP address for further use.

Preparing Raspberry Pi Board for Working With an Embedded Display

Oracle Java ME 8.3 supports working with any embedded display with the frame buffer interface such as Adafruit PiTFT 3.5" Touch Screen for Raspberry Pi.

This section explains how to prepare your board for working with the embedded display and contains the following topics:

Attaching the Embedded Display to the Raspberry Pi Board

Attach the embedded display using the high speed SPI interface on the Raspberry Pi board. For more information, see the manufacturer's site at

https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/overview

Installing the Customized Operating System Image on the Raspberry Pi Board

Download the customized Raspbian based raw image ZIP file to your desktop from the following site:

https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi/easy-install

Install the image into the Raspberry Pi board as described in Installing the Raspbian Pi Operating System on the Raspberry Pi Board.

Installing the Oracle Java ME Embedded Software

After you installed the customized operating system image, you must re-install the Java ME Embedded software using one of the following procedures:

Structure of the Oracle Java ME Embedded Software

Starting from version 8, the Oracle Java ME Embedded software contains a different architecture than previous versions. The user has an option to run a Developer Agent program on the desktop under Windows or Linux. Commands that are sent to the board from the host desktop are no longer sent directly across the network. Instead, they are sent to the Developer Agent program, which transmits all communication to and from the Oracle Java ME Embedded executable file on the Raspberry Pi board.

The Oracle Java ME Embedded ZIP archive consists of the following directories:

  • /appdb: This directory is used on the Raspberry Pi and contains internal Java libraries.

  • /bin: This directory is used on the Raspberry Pi and contains executables and the jwc_properties.ini file.

  • /legal: This directory contains important legal documentation.

  • /lib: This directory contains the files needed to compile IMlets on the Raspberry Pi board.

  • /util: This directory contains the Developer Agent program.

Installing the Oracle Java ME Embedded Software Using the Java ME SDK

This section describes how to install the Oracle Java ME Embedded Software on the Raspberry Pi board using the Oracle Java ME SDK. If you want to manually install the Java Embedded Software, see Installing the Oracle Java ME Embedded Software Manually.

  1. Install the Oracle Java ME SDK 8.3. For complete instructions, see Oracle Java ME SDK Developer's Guide.

  2. Start the Oracle Java ME SDK Device Connections Manager located in the <SDK Installation Folder>/bin directory and click its icon in the system tray. A Device Connections Manager window is shown in Figure 1-1.

    Figure 1-1 Device Connections Manager Window

    Description of Figure 1-1 follows
    Description of "Figure 1-1 Device Connections Manager Window"
  3. Press Ctrl+N or click the Setup new device button on the toolbar.

  4. Select the Raspberry Pi radio button and click Next. The Setup New Device window is shown in Figure 1-2.

    Figure 1-2 Setup New Device Window

    Description of Figure 1-2 follows
    Description of "Figure 1-2 Setup New Device Window"
  5. In the IP Address or Host Name, enter the IP address of the Raspberry Pi board, in the User Name and Password fields, enter the user name and password. Click Next.

  6. Choose the installation folder. By default, the Java ME Runtime is installed in the /home/pi/javame8.3 directory.

  7. Check the Start Java ME Runtime Now and Start Java ME Runtime on Boot check boxes and click Finish.

The Raspberry Pi device is now registered and has the Connected status in the Device Connections Manager window as shown in Figure 1-3.

Figure 1-3 Device Connections Manager Window with Raspberry Pi Connected

Description of Figure 1-3 follows
Description of "Figure 1-3 Device Connections Manager Window with Raspberry Pi Connected"

Installing the Oracle Java ME Embedded Software Manually

This section describes how to install the Oracle Java ME Embedded Software manually. Download the Oracle Java ME Embedded ZIP archive file and follow these steps:

  1. Use an sftp client or scp command to transfer a copy of the Oracle Java ME Embedded archive to the Raspberry Pi board.

    For example, on a UNIX or Mac system, you can transfer the ZIP file using a command similar to the following:

    $sftp pi@[IP address of board]
    

    Windows users can download the psftp.exe to obtain a free SFTP client which is available from the same address as the PuTTY executable:

    http://www.putty.org/

  2. After the ZIP archive is transferred, either go directly to the keyboard and the mouse connected to the Raspberry Pi board, or start a secure shell script on your desktop to connect to the board using the following command:
    $ssh -l pi [IP address of board]
    
  3. Unzip the archive on the Raspberry Pi board.
  4. Change to the bin directory.
    The contents of the bin directory are shown in Figure 1-4.

    Figure 1-4 Raspberry Pi Bin Directory

    Description of Figure 1-4 follows
    Description of "Figure 1-4 Raspberry Pi Bin Directory"
  5. Run the fix_permission.sh script to enable a privilege escalation mechanism.
    pi@raspberry ~/bin $ fix_permission.sh
    
    The fix_permission.sh provides the following functionality:
    • Sets an executable mode for all .sh files

    • Sets an executable mode for the runMidlet

    • Sets the network capabilities for the runMidlet by granting superuser privileges to perform various network-related operations

    • Enables the runMidlet to access the files required for the Device I/O functionality

Adding an HTTP Proxy for Network Connections on Raspberry Pi

If an HTTP proxy server is required for the Java IMlets on Raspberry Pi to make network connections (such as for HTTP or apt-get), then configure Oracle Java ME Embedded on Raspberry Pi by adding the following lines to the end of the bin/jwc_properties.ini file:

com.sun.midp.io.http.proxy.host = proxy.mycompany.com
com.sun.midp.io.http.proxy.port = 80

Downloading and Installing the PuTTY Terminal Emulator Program

The PuTTY terminal emulator is used to connect to the AMS command-line interface (CLI) that sends commands to the board.

Download the PuTTY terminal emulator program (putty.exe) from the following site:

http://www.putty.org/

Note:

Using the PuTTY terminal emulator program is highly recommended. You can use any terminal program to connect to the CLI, however, Oracle cannot guarantee that other terminal programs work with the CLI in the same manner as PuTTY.