Getting Started with the Oracle Java ME Embedded Client


Introduction

Installing Linux on an ARM-based BeagleBoard describes how to get Linux running on a BeagleBoard. This article describes how to create a Java application using NetBeans and how to run that application on the BeagleBoard using the Oracle Java Micro Edition Embedded Client (Oracle Java ME Embedded Client).


Get Software

Download the following:

  1. Oracle Java ME Embedded Client for ARM

    This is the Java platform that runs on the BeagleBoard. You will install it later in this article.

  2. Oracle Java ME Embedded Client for x86

    This package for x86 is the same Java platform software as the ARM package, but it runs on your computer and acts as a device simulator. This means you can write and test applications in a tight development cycle. When you get your application running well on your computer, you can start testing on a real device like the BeagleBoard. After you download this package, install it.

    alix@livadia:~$ sudo chmod +x ojec_1.0_linux_x86_sdk.bin
    alix@livadia:~$ sudo ./ojec_1.0_linux_x86_sdk.bin
    Oracle Java Micro Edition Embedded Client version 1.0 Installer
    is starting, please wait...
    1 - Install
    2 - Uninstall
    3 - Quit
    Enter choice: 1
    Installing Oracle Java Micro Edition Embedded Client version 1.0...
    Installation completed.
    
    alix@livadia:~$
  3. NetBeans version 6.9.1 or later

NetBeans is the Integrated Development Environment you use to create applications. Install NetBeans now.


Hook Up NetBeans

This section describes how to tell NetBeans about the Oracle Java ME Embedded Client so you can use it to create applications.

The following instructions were tested on an Ubuntu 10.04 system, but they should also apply to Windows. For more information, see the Installation Guide.

Start NetBeans, then select Tools > Java Platforms from the menu.

NetBeans Java Platform Manager window

Click Add Platform...

Choosing the platform type

Select Java ME CDC Platform Emulator, and click Next >.

Navigating to the directory

Go to the Oracle Java ME Embedded Client. The location depends on your operating system.

  • Linux: /usr/local/Oracle_JavaME_Embedded_Client
  • Windows 32-bit: C:\Program Files\Oracle\Oracle JavaME Embedded Client
  • Windows 64-bit: C:\Program Files (x86)\Oracle\Oracle JavaME Embedded Client

Select the emulator-platform subdirectory, and click Next >.

Choosing a platform name

Enter a name for the platform or accept the default, and click Finish.

Now the Oracle Java Micro Edition Embedded Client is in the list

The Java platform you just added is in the list. Click Close.


Create a NetBeans Project

This section describes how to create your first application for the Oracle Java ME Embedded Client.

Select File > New Project... from the NetBeans menu.

Choose a new project type

In Categories, select Java ME. In Projects, select CDC Application. Click Next.

Choose a name for the new project

Change the project name and location if you wish. Deselect Create Main Class and click Next.

Choose the platform for the new project

The name of the Oracle Java ME Embedded Client is shown as the Java Platform. Select JEC-1.0 for the Profile. Click Finish.

NetBeans creates a new project.


Create Source Code

This section describes how to write source code for your application.

In the Projects pane of the NetBeans window, right-click the project and select New > Java Class... from the menu.

Create a new class

Enter a class name and a package name. Click Finish. NetBeans supplies a skeleton of the class. Fill in an implementation that writes to the console:

package hello;

public class HelloMain {
  public static void main(String[] args) {
    System.out.println("Hello, Oracle Java Micro Edition Embedded Client!");
  }
}

Tell NetBeans that HelloMain is the main class of the project. Right-click the project, then select Properties (at the bottom of the menu). On the left side of the window, click Running. Click Browse, then select the class you just created.

Selecting a main class

Now that you downloaded and installed the software and know how to create an application using NetBeans, you can run your application on your desktop computer by clicking the button with the green triangle, pressing the F6 key, or selecting Run > Run Main Project from the menu.

If you do not see an Output window, press Ctrl 4. In that window, you see the output of your application running on the Oracle Java ME Embedded Client:

Hello, Oracle Java Micro Edition Embedded Client!

Run on the BeagleBoard

This section describes how to take the application you just created and run it on the BeagleBoard using the Oracle Java ME Embedded Client.

First, install the Oracle Java ME Embedded Client on the BeagleBoard. If you have your computer networked to the BeagleBoard, as described in Installing Linux on an ARM-Based BeagleBoard, then copying files over the network is easy. For example, if the BeagleBoard is at IP address 10.42.43.10 in your network, you can copy the Oracle Java ME Embedded Client archive:

alix@livadia:~$ scp Downloads/ojec_1.0_linux_arm_sdk.tar.gz \
ubuntu@10.42.43.10:/home/ubuntu
The authenticity of host '10.42.43.10 (10.42.43.10)' can't be established. RSA key fingerprint is 4e:eb:40:26:5a:61:26:65:87:8e:3c:06:2a:86:df:10. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.42.43.10' (RSA) to the list of known hosts. ubuntu@10.42.43.10's password: ojec_1.0_linux_ar.tar.gz 100% 8797KB 8.6MB/s 00:05 alix@livadia:~$

In the BeagleBoard console, unpack the archive:

ubuntu@omap:~$ tar zxvf ojec_1.0_linux_arm_sdk.tar.gz

If you are impatient, run the Java Virtual Machine now. You will see an error message that states you have not specified a main class, but you can verify that it runs.

ubuntu@omap:~$ Oracle_JavaME_Embedded_Client/binaries/production/bin/cvm 
Main class name missing.
usage: cvm [-fullversion] [-showversion] [-version] [-help] 
[-D<property>=<value>] [-XbuildOptions] [-XshowBuildOptions] [-XappName]
ubuntu@omap:~$ 

Copy your application to the BeagleBoard. NetBeans packages your application as a JAR file in a dist subdirectory of the project directory. Here is one example (on your computer again) of copying the application package to the microSD card:

alix@livadia:~$ scp NetBeansProjects/CdcApplication1/dist/CdcApplication1.jar \
ubuntu@10.42.43.10:/home/ubuntu

Try your application on the BeagleBoard:

ubuntu@omap:~# Oracle_JavaME_Embedded_Client/binaries/production/bin/cvm \
-cp CdcApplication1.jar hello.HelloMain
Hello, Oracle Java Micro Edition Embedded Client! ubuntu@omap:~#

You just ran your first application on the Oracle Java ME Embedded Client on ARM hardware!

If the command line is too cumbersome, you can simplify it:

ubuntu@omap:~# alias \
cvm=/home/ubuntu/Oracle_JavaME_Embedded_Client/binaries/production/bin/cvm
ubuntu@omap:~# cvm -cp CdcApplication1.jar hello.HelloMain Hello, Oracle Java Micro Edition Embedded Client! ubuntu@omap:~#

Summary

Installing Linux on an ARM-Based BeagleBoard describes how to prepare a memory card and run Linux on a BeagleBoard. This article describes how to use NetBeans to create an application for the Oracle Java ME Embedded Client. It also shows how to run that application on a desktop computer using NetBeans and how to run the same application on the BeagleBoard.

You now have the knowledge and tools to create Java applications for the Oracle Java ME Embedded Client for either x86 or ARM processors.