Skip Headers
Oracle® Java ME Embedded Getting Started Guide for the Windows Platform
Release 8 EA 2 for NetBeans on Windows
E48511-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

Beta Draft: 2014-02-15

2 Creating an ME SDK 8 Sample Project

This chapter describes the NetBeans 8.0 Beta integrated development environment. NetBeans 8.0 Beta provides a rich, visual environment for developing embedded applications and numerous tools to improve the programming process.

Oracle Java ME SDK provides two plugins for working with NetBeans 8.0 Beta:

The Java ME SDK Demos plugin is optional, but recommended.

Downloading Oracle Java ME SDK Plugins

To download the Oracle Java ME SDK 8 EA 2 Plugins file for NetBeans (oracle-jmesdk-8-0-ea2-nb-plugins.zip) go to the following location:

http://www.oracle.com/technetwork/java/javame/javamobile/download/sdk

Installing Oracle Java ME SDK 8.0 EA Plugins

To install the NetBeans Plugins:

  1. Extract the contents of the NetBeans Plugins file to a directory on your local machine. Make note of the location.

  2. Open the NetBeans Plugins Manager. Select:

    Tools > Plugins

  3. Uninstall previous plugins.

  4. If not already open, re-open the Plugins Manager and click the Settings tab. Make sure that Additional Development Plugins and Latest Development Build are unchecked, as shown in Figure 2-2.

    Figure 2-2 The Settings Tab

    Description of Figure 2-2 follows
    Description of "Figure 2-2 The Settings Tab"

  5. Click the Add button in the lower right. This displays the Update Center Customizer box.

  6. In the Update Center Customizer box, do the following, as shown in Figure 2-3:

    • In the Name field, enter New Update Center.

    • Select the Check for updates automatically box.

    • In the URL field, use the file command to point to the location where you have unzipped your plugins. For example:

    • file:/C:/My_Update_Center_Plugins/updates.xml

    Figure 2-3 Adding Plugins

    Description of Figure 2-3 follows
    Description of "Figure 2-3 Adding Plugins"

  7. Click OK. This adds the New Update Center to the Settings tab.

  8. Select the New Update Center, as shown in Figure 2-4.

    Figure 2-4 Selecting the New Update Center

    Description of Figure 2-4 follows
    Description of "Figure 2-4 Selecting the New Update Center"

  9. Go to the Available Plugins tab and select Java ME SDK Tools and Java ME SDK Demos, as shown in Figure 2-5, and click Install.

    Figure 2-5 Selecting Available Plugins

    Description of Figure 2-5 follows
    Description of "Figure 2-5 Selecting Available Plugins"

  10. When the NetBeans IDE Installer screen is displayed, as shown in Figure 2-6, click Next.

    • Accept the license terms and click Install.

    • If additional Validation screens appear, click Continue.

    Figure 2-6 The NetBeans IDE Plugin Installer

    Description of Figure 2-6 follows
    Description of "Figure 2-6 The NetBeans IDE Plugin Installer"

  11. Click Finish to restart NetBeans 8.0 Beta.

  12. When NetBeans 8.0 Beta has restarted, select Tools > Plugins to display the Plugins screen.

  13. In the Installed tab, check Show details and click Category to sort the plugins.

    • Find the Java ME SDK Tools and Java ME SDK Demos plugins in the list.

    • Make sure the plugins you have installed are Active (you should see a green check mark), as shown in Figure 2-7.

    • If the Oracle Java ME SDK 8 EA 2 plugins are not Active, check the Select boxes for the plugins and click Activate.

    Figure 2-7 Activated Plugins

    Description of Figure 2-7 follows
    Description of "Figure 2-7 Activated Plugins"

  14. When your Oracle Java ME SDK 8 EA 2 plugins are Active, click Close.

Creating a Sample IMlet File

In this section, you create a sample IMlet file, IMletDemo.java, from the code provided in Example 2-1. This IMlet file is used in the next section, "Creating a New Project".

  1. Copy the code shown in Example 2-1 into a text file. Use Notepad rather than WordPad, to avoid any unneeded extra characters.

  2. Name the file IMletDemo.java and Save. Set the file aside for now.

Example 2-1 Code for the Sample IMletDemo.java Project in NetBeans 8.0 Beta

package javameapplication1;
import javax.microedition.midlet.MIDlet;

public class IMletDemo extends MIDlet {

     boolean bFirst = false;

     public void startApp() {

            try {
                // Perform startup operations
            } catch (Exception ex) {
                ex.printStackTrace();
                return;
            }

            bFirst = true;
              System.out.println("IMlet Demo is already started...");
         // Start program here

}
    public void pauseApp() {
         //  Pause the application
    }

    public void destroyApp(boolean unconditional) {
       // Close all resources that have been opened

    }


}

Creating a New Project

This section walks you through creating a new embedded project using the Oracle Java ME SDK 8 EA 2 and NetBeans 8.0 Beta platforms.

  1. Choose File > New Project. The New Project dialog box appears.

  2. Choose Java ME Embedded from the Categories list and Java ME Embedded Application from the Projects list, as shown in Figure 2-8.

    Figure 2-8 The New Project Screen

    Description of Figure 2-8 follows
    Description of "Figure 2-8 The New Project Screen"

  3. Press the Next button. This shows the New Java ME Embedded Application window, as shown in Figure 2-9.

    Figure 2-9 The New Java ME Embedded Application Screen

    Description of Figure 2-9 follows
    Description of "Figure 2-9 The New Java ME Embedded Application Screen"

  4. Accept the defaults and click Finish.

  5. The NetBeans 8.0 Beta New Project screen is displayed for the project you have just created, containing a minimal default code sample, as shown in Figure 2-10.

    Figure 2-10 Sample Code for The Newly-Created Java ME Application

    Description of Figure 2-10 follows
    Description of "Figure 2-10 Sample Code for The Newly-Created Java ME Application"

Including Your Sample IMlet Code

Now you can update the generic project with the sample code you created earlier in Creating a Sample IMlet File. The NetBeans 8.0 Beta Projects window is visible in Figure 2-11.

Figure 2-11 The NetBeans Projects Window

Description of Figure 2-11 follows
Description of "Figure 2-11 The NetBeans Projects Window"

  1. Right click to select JavaMEApplication1 in the Projects window, as shown in Figure 2-12 and select Properties from the drop-down menu.

    Figure 2-12 The JavaMEApplication1.java Project

    Description of Figure 2-12 follows
    Description of "Figure 2-12 The JavaMEApplication1.java Project"

  2. This displays the JavaMEApplication1 Properties window.

    To see the path to the location of the JavaMEApplication1 file, look in the All Files line. Make a note of this path, as shown in Figure 2-13.

    Figure 2-13 The JavaMEApplication1.java Properties Screen

    Description of Figure 2-13 follows
    Description of "Figure 2-13 The JavaMEApplication1.java Properties Screen"

  3. Take the IMletDemo.java file you created in Creating a Sample IMlet File and copy it into the javameapplication1 directory in the file path you noted.

  4. Delete the file JavaMEApplication1.java or remove it from the directory.

  5. This changes the content of the NetBeans 8.0 Beta Project window to the content in the IMletDemo.java file, as shown in Figure 2-14. (If it does not display, double-click IMletDemo.java in the Projects window.)

    Figure 2-14 The NetBeans 8.0 Beta Project Window with the IMletDemo Project

    Description of Figure 2-14 follows
    Description of "Figure 2-14 The NetBeans 8.0 Beta Project Window with the IMletDemo Project"

  6. Right click on the package name javameapplication1 in the Projects window, as shown in Figure 2-15.

    Figure 2-15 Selecting the javameapplication1 Package

    Description of Figure 2-15 follows
    Description of "Figure 2-15 Selecting the javameapplication1 Package"

  7. Select File > Project Properties (JavaMEApplication1).

    This displays the JavaMEApplication1 Properties box, as shown in Figure 2-16.

    Figure 2-16 The JavaMEApplication1 Properties Box

    Description of Figure 2-16 follows
    Description of "Figure 2-16 The JavaMEApplication1 Properties Box"

  8. Select the Application Descriptor category.

    This displays the Application Descriptor window, with attributes of the JAD and Jar Manifest for the default MIDlet suite, as shown Figure 2-17.

    Figure 2-17 The Application Descriptor Window with MIDlet Manifest Settings

    Description of Figure 2-17 follows
    Description of "Figure 2-17 The Application Descriptor Window with MIDlet Manifest Settings"

  9. Select the MIDlets tab. The Class name in the MIDlet row is flagged red, as shown in Figure 2-18.

    Figure 2-18 The MIDlet Class Name

    Description of Figure 2-18 follows
    Description of "Figure 2-18 The MIDlet Class Name"

  10. Select the MIDlet row. This flags the row dark blue and activates the Edit button, as shown in Figure 2-19.

    Figure 2-19 The MIDlets Tab with the Edit Button Active

    Description of Figure 2-19 follows
    Description of "Figure 2-19 The MIDlets Tab with the Edit Button Active"

  11. Press the Edit button to display the Edit MIDlet dialog box.

  12. Use the drop-down list to change the MIDlet class to javameapplication1.IMletDemo, as shown in Figure 2-20, and press OK.

    Figure 2-20 The Edit MIDlet Dialog Box

    Description of Figure 2-20 follows
    Description of "Figure 2-20 The Edit MIDlet Dialog Box"

  13. The MIDlet Class is now updated in the MIDlets tab., as shown in Figure 2-21. Press OK to close the Properties window.

    Figure 2-21 The Updated MIDlet Properties Class

    Description of Figure 2-21 follows
    Description of "Figure 2-21 The Updated MIDlet Properties Class"

  14. Clean and build the JavaMEApplication1 project by clicking on the hammer-and-broom icon in the NetBeans 8.0 Beta toolbar, as shown in Figure 2-22, or by selecting Run > Clean and Build Project (JavaMEApplication1).

    Figure 2-22 The NetBeans 8.0 Beta Toolbar and Menus

    Description of Figure 2-22 follows
    Description of "Figure 2-22 The NetBeans 8.0 Beta Toolbar and Menus"

  15. Run the newly cleaned and built JavaMEApplication1 project by selecting the green right-arrow icon in the NetBeans 8.0 Beta toolbar or by selecting Run > Run Project (JavaMEApplication1).

    When the Run is successful, the EmbeddedDevice1 emulator starts with the JavaMEApplication1 Suite running, as shown in Figure 2-23.

    Figure 2-23 The Running EmbeddedDevice1 Emulator Window

    Description of Figure 2-23 follows
    Description of "Figure 2-23 The Running EmbeddedDevice1 Emulator Window"