Chapter 4
Working With Eclipse
This chapter details the steps to configure Eclipse to use the Oracle Java
ME Embedded Client SDK as a Java platform, and presents a sample project
and a sample application to run in your configured environment.
Note - The SDK supports application development and the emulation. Debugging and Profiling are not
supported.
Oracle Java ME Embedded Client SDK and Eclipse Projects
This section describes how to add the Oracle Java ME Embedded Client
SDK as a Platform in Eclipse and how to create a new project
in Eclipse.
Adding a Java Platform
Before You Begin
Launch Eclipse and follow these steps:
- Select Window > Preferences.
The Preferences Window opens.
- In the Preferences window, go to the left panel, expand the Java item,
and select Installed JREs.
![The Add JRE window lists the installed JRE types in the central panel. Click the Add button. The Add JRE window lists the installed JRE types in the central panel. Click the Add button.](figures/ec1.jpg)
The central panel displays the JREs on this machine.
- Click the Add button on the right to open the Add JRE window.
The window displays the JRE Type options.
- Select Execution Environment Description and click Next.
![Select Execution Environment Description (the first JRE type) and click the Next button on the bottom center Select Execution Environment Description (the first JRE type) and click the Next button on the bottom center](figures/ec2.jpg)
The window displays the JRE definition panel.
- In the Definition File field, click File to open a file chooser window.
- Navigate to /usr/local/Oracle_JavaME_Embedded_Client/1.0/emulator-platform .
![Click the File button on the upper right, browse to the SDK installation directory, and locate /emulator-platform/ojec_re_def.ee. Click Next. With the file chosen the JRE name should read Oracle Java Micro Edition Embedded Client 1.0. The default VM arguments are -Djava.home=”path_to_emulator-platform” Click the File button on the upper right, browse to the SDK installation directory, and locate /emulator-platform/ojec_re_def.ee. Click Next. With the file chosen the JRE name should read Oracle Java Micro Edition Embedded Client 1.0. The default VM arguments are -Djava.home=”path_to_emulator-platform”](figures/ec5.jpg)
- Select ojec_re_def.ee and click OK to close the file chooser window.
- Click Finish to load the Oracle Java ME Embedded Client JRE and close
the Add JRE window.
The Installed JREs panel lists Oracle Java Micro Edition Embedded Client 1.0 as
an installed JRE.
- Check the box in front of Oracle Java Micro Edition Embedded Client 1.0
and click OK.
![Click the check box in front of Oracle Java Micro Edition Embedded Client and click OK. Click the check box in front of Oracle Java Micro Edition Embedded Client and click OK.](figures/ec6.jpg)
Now you are ready to develop applications for the Oracle Java ME
Embedded Client.
Writing Your First Application
After completing the steps documented in the previous task, Eclipse has the JRE
platform required to build and run Oracle Java ME Embedded Client applications.
- Select File > New > Project and then Java Project.
The Create a Java Project window is displayed.
- In the Create a Java Project window, perform the following actions:
![The New Java Project window with project name and Oracle Java Micro Edition Embedded client JRE specified for Project Specific JRE The New Java Project window with project name and Oracle Java Micro Edition Embedded client JRE specified for Project Specific JRE](figures/ec8.jpg)
- Enter a project name, such as HelloWorld.
- In the JRE area, select Use a project specific JRE and choose Oracle
Java Micro Edition Embedded Client 1.0.
- For this example, choose Create separate folders for sources and class files.
- Click the Finish button.
The new project HelloWorld is created along with separate directories for sources and
class files, src and bin respectively.
- Select File > New > Class.
The New Java Class window opens.
- In the New Java Class window, perform the following actions:
![The New File window showing the project hierarchy The New File window showing the project hierarchy](figures/ec7.jpg)
- The Source folder field should be populated. If it isn’t, browse for the
folder.
- In the Package field, use lower case characters to enter a name.
- In the Name field, enter the class file name.
- In the method stubs area, deselect the Inherited abstract methods option and check:
public static void main(String[] args)
- Click Finish to create the file Hello.java in the src folder.
The new Hello.java file in the src folder is an empty template
and must be modified.
- In Hello.java, add a print line to the body of the main function:
package hello;
public class Hello {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World");
}
}
- Click the green triangle Run button to compile and run your code.
The Hello World message prints in the console.