Creating a New project with NetBeans

A project contains information about programs files and IDE environment settings. To create a new project click on  File->New Project… (Ctrl+Shift+N). Then a window like the one in the Figure 2 appears.

 

Figure 2

After choosing Mobile Application, click on “next” button. The window shown in the Figure 3 pops up and information about the project name and its location on the file system are required to be inserted.

Figure 3


By clicking on “Next” another window shows up and the Emulator Platform can be chosen if other third-party emulators are installed. Otherwise the default J2ME Wireless toolkit 2.2 is used. Moreover the device configuration and profile can be set to better emulate the target device. See Figure 4.

 

 

Figure 4

By pressing the “Finish” button, the new project creation is done. Next step is to add MIDlets and all the other classes needed by the application to the project.

 

Creating a new MIDlet

The MIDlet class is the core of the application. The steps for creating a new MIDlet class are shown below.
By right clicking on the “<default package>”->New->MIDlet… in the Project tab a new window appears, as the one shown in the Figure 5.

 

Figure 5

After you have inserted all the information about the class name and you have clicked on “Finish” button, the main window of NetBeans displays the skeleton of the HelloWorld MIDlet as shown in the Figure 6.

 

Figure 6

Now you can insert the lines of code you need for your application.

Building and running the project

After having inserted the code in the HelloWorld.java file and saved the project by pressing File->Save (Ctrl+S), the project is ready to be built. Click on Build->Build Main Project (F11) and NetBeans will start to compile the project, as shown in the Figure 7. In the Output window, information about the building process are displayed.

Figure 7

If no errors occur, you can run the project to start the emulator by clicking on Run->Run Main Project (F6), as shown in the Figure 8.

 

 

Figure 8

The emulator pops up on the screen and you can launch the application now by clicking on the right soft button on the phone emulator.
The application is now running on the emulator and on the screen of the phone you can see the “Hello World” message as shown in the Figure 9.

 

Figure 9

Before you start developing an application you may have to decide which device your application is target for. It will help you to choose the proper emulator to use. To this purpose NetBeans can integrate other third-party emulators which look like real devices on the market. In fact the screen size and graphical interface of the default Wireless Toolkit emulator do not look like a specific mobile phone.

MIDlet on the Phone

When the project is built, NetBeans creates the MIDlet Suite for the project. In the HelloWorld/dist folder two new files are created: HelloWorld.jad and Helloworld.jar as shown in the Figure 10.
The latter one is the archive that contains all the files needed by the application to work. Therefore, for installing the MIDlet on the phone, this file needs to be transferred to it.
There are two ways of sending the application on a real device for installing it:

  • Using the software that the vendor of the handset provides, such as Nokia PC Suite software (http://www.nokia.com) for Nokia phones.
  • Using Infrared or Bluetooth technology

As soon as the .jar file is sent to the phone, the installation process starts by clicking on the received file.

Figure 10

Department of Electronic Systems | Aalborg University | Niels Jernes Vej 12 | DK-9220 Aalborg | Denmark
Phone: (+45) 9635 8695 | Fax (+45) 9815 1583 | E-mail ies(at)ies.aau.dk
Copyright © 2006 Department of Electronic Systems

Last update:11-10-2006