Skip Headers
Oracle® Java ME Embedded Getting Started Guide for the Windows Platform
Release 3.3
E35132-02
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

2 Using the Oracle Java ME SDK Software with NetBeans

This chapter describes the NetBeans integrated development environment. NetBeans 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:

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

Downloading Oracle Java ME SDK Plugins

To download the Oracle Java ME SDK Plugins file for NetBeans (oracle-jmesdk-3-3-rr-nb-plugins.zip) go to the following location:

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

Installing Oracle Java ME SDK Plugins

There are two ways to install the Oracle Java ME SDK Plugins:


Note:

Using the NetBeans Update Center to install the plugins is recommended. However, installing the plugins manually also works.


To get the plugins ready for installation, start NetBeans as described in Chapter 1

Installing Plugins Using the Update Center

To install the NetBeans Plugins using the NetBeans Update Center:

  1. Select Tools > Plugins to open the NetBeans Plugins manager, as shown in Figure 2-1.

    Figure 2-1 The NetBeans Plugin Manager

    Description of Figure 2-1 follows
    Description of "Figure 2-1 The NetBeans Plugin Manager"

  2. Click the Settings tab. This displays the available update centers, as shown in Figure 2-2.

    Figure 2-2 Adding a Plugin Portal

    Description of Figure 2-2 follows
    Description of "Figure 2-2 Adding a Plugin Portal"

  3. Click the Add button. In the new window, type a provider name and a URL for the location that contains the plugin center files, as shown in Figure 2-3.

    Figure 2-3 Creating a New Update Center

    Description of Figure 2-3 follows
    Description of "Figure 2-3 Creating a New Update Center"

  4. When plugins are detected, they are displayed on the Available Plugins tab. If you do not see them, click the Check for Updates button.

  5. Restart NetBeans.

  6. In the Plugins Manager Settings tab, enable all available update centers.

  7. In the Installed tab, check Show details (above the plugin list) and sort by category to easily find the Java ME SDK Tools plugins.

    • Make sure the plugins you installed are active (with a green check mark), as shown in Figure 2-5.

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

    Figure 2-5 The Plugins Manager Installed Tab

    Description of Figure 2-5 follows
    Description of "Figure 2-5 The Plugins Manager Installed Tab"

The Oracle Java ME SDK is ready to use. For more information on how to verify your plugin installation, see

Installing NetBeans Plugins Manually

To install the NetBeans Plugins manually.

  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. Re-open the Plugins Manager and click the Downloaded tab, as shown in Figure 2-7.

  5. Click the Add Plugins button.

    Figure 2-7 The Downloaded Tab and Add Plugins Button

    Description of Figure 2-7 follows
    Description of "Figure 2-7 The Downloaded Tab and Add Plugins Button"

  6. In the file browser, go to the directory in which you have extracted the contents of the NetBeans Plugins.

  7. Select all the .nbm files and click Open, as shown in Figure 2-8.

    Figure 2-8 Adding Plugins

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

  8. Go to the Downloaded tab and select all downloaded plugins, as shown in Figure 2-9, and click Install.

    Figure 2-9 Selecting Downloaded Plugins

    Description of Figure 2-9 follows
    Description of "Figure 2-9 Selecting Downloaded Plugins"

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

    • Accept the license terms and click Install.

    • If additional Validation screens appear, click Continue.

    Figure 2-10 The NetBeans IDE Installer

    Description of Figure 2-10 follows
    Description of "Figure 2-10 The NetBeans IDE Installer"

  10. Click Finish to restart NetBeans.

  11. Select Tools > Plugins to display the Plugins screen.

  12. 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 installed are Active (you should see a green check mark), as shown in Figure 2-6.

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

  13. When your Oracle Java ME SDK plugins are Active, click Close.

    The Oracle Java ME SDK is ready to use. For more information on how to verify your plugin installation, see

Verifying Your Installation

Once you have installed the Oracle Java ME SDK Plugins into NetBeans (using the Update Center or by manual installation), the Oracle Java ME SDK platform is installed into the NetBeans IDE. To verify a successful installation, do the following:

  1. To verify the Active Device Manager, select Tools > Java ME > Active Device Manager, and select the latest version (Oracle Java ME SDK 3.3).

  2. To view available Oracle Java ME SDK 3.3 devices, select Tools > Java ME > Device Selector. The ME SDK devices are listed, as shown in Figure 2-11.

    Figure 2-11 The Device Selector

    Description of Figure 2-11 follows
    Description of "Figure 2-11 The Device Selector"

  3. To display the new Oracle Java ME SDK platform, choose Tools > Java Platforms. This displays the Java Platform Manager with the new platform, as shown in Figure 2-12.

    Figure 2-12 The Java Platform Manager

    Description of Figure 2-12 follows
    Description of "Figure 2-12 The Java Platform Manager"

The Oracle ME SDK Platform is now ready for you to work with, to create a new project and develop code, as shown in the following sections.

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

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

public class IMletDemo extends MIDlet {

     boolean bFirst = false;
     boolean loopFlag = true;


     public void startApp() {

         if (bFirst = false) {

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

            bFirst = true;
         } else {
              System.out.println("IMlet Demo is already started...");
         }

         // Start program here

    }

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

    public void destroyApp(boolean unconditional) {
       bFirst = false;

       // 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 and NetBeans platforms.

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

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

    Figure 2-13 The New Project Screen

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

  3. Press the Next button. This shows the The New Embedded Application dialog box, with EmbeddedApplication1 in the Name and Location panel.

  4. Enter IMletDemo as the Project Name.

  5. Accept the default Project Location or browse to select it. Ensure that the Create Default Package and IMlet Class option is checked, as shown in Figure 2-14. Click Next.

    Figure 2-14 Creating a New Project

    Description of Figure 2-14 follows
    Description of "Figure 2-14 Creating a New Project"

  6. The Default Platform Selection is displayed. In the Emulator Platform box, choose "Oracle Java(TM) Platform Micro Edition 3.3." Choose "IMPNGDevice1" for the Device, "CLDC 1.1" for the Device Configuration, and "IMP-NG" for the Device Profile, as shown in Figure 2-15. Press Finish.

    Figure 2-15 Setting the New Default Platform

    Description of Figure 2-15 follows
    Description of "Figure 2-15 Setting the New Default Platform"

  7. This More Configurations Selection box is displayed, as shown in Figure 2-16. Accept the defaults or add additional configurations. Press Finish.

    Figure 2-16 Adding More Configurations

    Description of Figure 2-16 follows
    Description of "Figure 2-16 Adding More Configurations"

  8. The NetBeans New Project screen is displayed for the project you have just created, containing default minimal sample code, as shown in Figure 2-17

Figure 2-17 The New IMletDemo Project

Description of Figure 2-17 follows
Description of "Figure 2-17 The New IMletDemo Project"

Including Your Sample IMlet Code

Now you can update the generic project with the sample code you created earlier in The NetBeans Projects window looks like Figure 2-18.

Figure 2-18 The IMletDemo Project Tree

Description of Figure 2-18 follows
Description of "Figure 2-18 The IMletDemo Project Tree"

  1. Right click to select IMlet.java in the Projects window.

  2. Select Refactor --> Rename to display the Rename Class IMlet dialog box.

  3. In the Rename Class IMlet dialog box, enter IMletDemo. Ensure that Apply Rename on Comments is checked, as shown in Figure 2-19. Press Refactor.

    Figure 2-19 The Rename Class IMlet Dialog Box

    Description of Figure 2-19 follows
    Description of "Figure 2-19 The Rename Class IMlet Dialog Box"

  4. This changes the name in the Projects window to IMletDemo.java, as shown in Figure 2-20. Right click IMletDemo.java and select Properties.

    Figure 2-20 The IMletDemo Projects Window

    Description of Figure 2-20 follows
    Description of "Figure 2-20 The IMletDemo Projects Window"

  5. This displays the IMletDemo.java - Properties window. To see the path to the location of the newly-refactored IMletDemo.java file, look in the All Files line, as shown in Figure 2-21. Make a note of this path.

    Figure 2-21 The IMletDemo Properties Window

    Description of Figure 2-21 follows
    Description of "Figure 2-21 The IMletDemo Properties Window"

  6. Take the IMletDemo.java file you created in "Creating a Sample IMlet File" and use it to overwrite the IMletDemo.java file in the path location you have just noted. When it asks you to confirm the File Replace, click Yes.

  7. This changes the content of the NetBeans Project window to the content contained in the newly-added IMletDemo.java file, as shown in Figure 2-22. (If it does not double-click IMletDemo.java in the Projects window.

    Figure 2-22 The NetBeans Project Window with the IMletDemo Project

    Description of Figure 2-22 follows
    Description of "Figure 2-22 The NetBeans Project Window with the IMletDemo Project"

  8. Clean and build the IMletDemo project by clicking on the hammer-and-broom icon in the NetBeans toolbar, as shown in Figure 2-23, or by selecting Run > Clean and Build Project (IMletDemo).

    Figure 2-23 The NetBeans Toolbar and Menus

    Description of Figure 2-23 follows
    Description of "Figure 2-23 The NetBeans Toolbar and Menus"

  9. Run the newly cleaned and built IMletDemo project by selecting the green right-arrow icon in the NetBeans toolbar or by selecting Run > Run Project (IMletDemo).

    When the Run is successful, the IMPNGDevice1 emulator starts with the IMletDemo Suite running, as shown in Figure 2-24.

    Figure 2-24 The NetBeans Emulator Window Running the IMletDemo Project

    Description of Figure 2-24 follows
    Description of "Figure 2-24 The NetBeans Emulator Window Running the IMletDemo Project"

For more information about the emulator, see Chapter 3, "Using the Emulator".