Oracle® Java ME Embedded Getting Started Guide for the Windows Platform Release 8 EA 2 for NetBeans on Windows E48511-01 |
|
Previous |
Next |
Beta Draft: 2014-02-15
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:
Java ME SDK Tools plugin
Java ME SDK Demos plugin
The Java ME SDK Demos plugin is optional, but recommended.
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
To install the NetBeans Plugins:
Extract the contents of the NetBeans Plugins file to a directory on your local machine. Make note of the location.
Open the NetBeans Plugins Manager. Select:
Tools > Plugins
Uninstall previous plugins.
Go to the Installed tab and click Show details.
Check Java ME SDK Tools
and Java ME SDK Demos
, as shown in Figure 2-1.
Note: If the previous plugins have already been uninstalled, go to Step 4. |
Figure 2-1 NetBeans Plugins Manager Window
Click Uninstall.
Restart when requested.
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.
Click the Add button in the lower right. This displays the Update Center Customizer box.
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
Click OK. This adds the New Update Center to the Settings tab.
Select the New Update Center, as shown in Figure 2-4.
Figure 2-4 Selecting the New Update Center
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.
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
Click Finish to restart NetBeans 8.0 Beta.
When NetBeans 8.0 Beta has restarted, select Tools > Plugins to display the Plugins screen.
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.
When your Oracle Java ME SDK 8 EA 2 plugins are Active, click Close.
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".
Copy the code shown in Example 2-1 into a text file. Use Notepad rather than WordPad, to avoid any unneeded extra characters.
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 } }
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.
Choose File > New Project. The New Project dialog box appears.
Choose Java ME Embedded from the Categories list and Java ME Embedded Application from the Projects list, as shown in Figure 2-8.
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
Accept the defaults and click Finish.
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
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.
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
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
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.
Delete the file JavaMEApplication1.java
or remove it from the directory.
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
Right click on the package name javameapplication1
in the Projects window, as shown in Figure 2-15.
Figure 2-15 Selecting the javameapplication1 Package
Select File > Project Properties (JavaMEApplication1).
This displays the JavaMEApplication1 Properties box, as shown in Figure 2-16.
Figure 2-16 The JavaMEApplication1 Properties Box
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
Select the MIDlets tab. The Class name in the MIDlet row is flagged red, as shown in Figure 2-18.
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
Press the Edit button to display the Edit MIDlet dialog box.
Use the drop-down list to change the MIDlet
class to javameapplication1.IMletDemo
, as shown in Figure 2-20, and press OK.
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
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
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