×
Namespaces

Variants
Actions
Revision as of 04:25, 13 October 2011 by hamishwillee (Talk | contribs)

NetBeans

From Nokia Developer Wiki
Jump to: navigation, search
{{{width}}}
18 Sep
2009
{{{width}}}
26 Apr
2009
Article Metadata

This Wiki page provides an overview of the features of NetBeans for creating mobile Java™ applications. It then provides a simple introduction to creating a mobile Java application.

Contents

Introduction

The NetBeans IDE is an open-source integrated development environment based on the NetBeans Platform and has been written entirely in the Java language. The NetBeans IDE supports development for all Java application types (such as Java SE, Web, EJB, and Java ME mobile applications). Among other key features are an Apache Ant-based project system, version control, and refactoring tools.

For mobile development, NetBeans provides many Rapid Application Development (RAD) features, such as a Visual Flow Designer, Visual Form Designer, and tools for multitarget development.

To enable the use of NetBeans by developers building mobile Java applications for devices, Nokia has provided support for NetBeans in many of the Series 40 and S60 SDKs, including all the recent Series 40 5th Edition and S60 3rd Edition SDKs.

Mobile Java developers may also be interested in the UML plug-in. This plug-in enables developers to design UML diagrams as Class Diagrams and to synchronize code with them. The UML plug-in is available in the All package of NetBeans or can be loaded into NetBeans using the IDE's plug-in manager (by selecting Tools -> Plugins from the menu).

Following are some of the key features of NetBeans for development of Java applications:

  • Code completion.
  • Javadoc™ help.
  • Many refactoring features.
  • Code assistant.
  • Project view.
  • The availability of many additional tools and plug-ins.

The current version of NetBeans is 6.5.1 and can be downloaded from http://netbeans.org/downloads/index.html. To develop mobile Java applications, developers should download the Java or All packages, which support Java ME development.

Download NetBeans

Following are some of the key features of NetBeans for development of mobile Java applications:

  • Application Flow Designer.
  • Screen Designer.
  • Code analyzer.
  • A modular build system.
  • Application porting support.
  • Wireless connection wizard (available in the All package).
  • Scalable 2D Vector Graphics API for J2ME™ (JSR 226) support.
  • Various deployment options, including deployment to a Nokia device using Nokia PC Suite.
  • Project support.
  • Integrated development tools.
  • J2MEUnit testing support.
  • Integrated obfuscation and optimization support.

For more information on these features, see the Nokia Developer NetBeans page.

Getting started with NetBeans

Creating a new Java ME project with NetBeans

A NetBeans project contains information about program files and IDE environment settings. To create a new project, select File -> New Project... from the NetBeans menu or use the Ctrl+Shift+N keyboard shortcut. The window shown in the following figure will open.

NetBeans New Project.jpg

Choose Java ME from the Categories list and then Mobile Application from the Projects list. Selecting the Next button opens the dialog shown in the following figure.

03 New Project.jpg

Name the project and choose a location on the file system in which to store it. Note the option Create Hello MIDlet. Choosing this option will create a simple "Hello World"-style application, but more important, it will initialize the application to use the visual designers for application flow and screen layouts. Again, select the Next button, and the dialog shown in the following figure opens.

04 New Project.jpg

If the Create Hello MIDlet option is not selected, you will have to create a MIDlet yourself after the project is created. For this, go to File -> New File..., select MIDP in the Categories list and MIDlet in the File Types list. Press Next, give your MIDlet a name and press Finish.

Now select the Emulator Platform the application will be coded against. You can use most of the S60 and Series 40 SDKs. In this case, the S60 3rd Edition, Feature Pack 2 SDK for Symbian OS, for Java has been selected. At this stage, the S60Emulator device is selected to enable testing of the application on a PC, using the emulator supplied in the SDK. Once again, select Next, and the following dialog is displayed.

05 New Project.jpg

This dialog allows additional configurations to be added to a project. For a first application, no additional configurations are needed, so simply select Finish to complete the New Project wizard.

Creating a flow, building screens, and adding code

Once the project has been created, NetBeans will display the Flow Designer in the NetBeans editor, as shown in the following figure.

NetBeans flow.jpg

Create the application flow by dragging elements from Displayables, located under the Palette (in the right-hand window of the IDE) into the Flow Designer. Then grab commands and drag them to the displayable that they are required to flow to.

Once the flow has been created, individual screens can be created. This is done by selecting the displayable and then selecting the Screen tab in the Visual Designer. A screen similar to the one shown in the following figure will be displayed.

NetBeans screen.jpg

As with the Flow Designer, screen components can now be dragged into the Device Screen and edited to create the desired effect. Once the screen has been designed, the code can be modified to implement the application-specific business logic. Select the Source tab to open the code. A screen similar to the one in the following figure will be displayed.

NetBeans source.jpg

When the source view is first opened, all the code generated by the flow and screen designers is in minimized code blocks labeled Generated.... Expand these code blocks to see the generated code highlighted in gray. This code cannot be changed. The application-specific code can be inserted in the sections of the code that are not highlighted.

With these tools, applications can be developed relatively quickly. In addition, it is worth noting that NetBeans provides features for taking advantage of JSR 226 and SVGT content. JSR 226 enables highly graphical content to be created with tools such as Adobe Illustrator and Ikivo Animator, eliminating the need to program graphics for menus and a range of application screens.

Building the project and running it in the emulator

Having created the application with the Visual Designer and added any business logic, save the project by selecting File -> Save from the NetBeans menu (or by using the keyboard shortcut Ctrl+S). Now the project can be built. To do so, select Run -> Build Main Project from the NetBeans menu (or press the F11 key). NetBeans will start to compile the project, as shown in the following figure. Information on the build process is displayed in the Output window at the bottom of the IDE.

NetBeans build project.jpg

If there are no errors in the build process, the project can now be run in the S60 emulator. To do so, select Run -> Run Main Project from the NetBeans menu (or press F6). First, a dialog showing launch progress is displayed, as shown in the following figure.

10 New project SDK launch.jpg

The emulator is then opened and the application started, as shown in the following figure.

11 Emulator.jpg

The application can now be tested to confirm that it behaves in the manner expected. Once testing has finished, the application can be closed; however, the emulator should be left open if more testing is planned. Leaving the emulator open improves the speed of deploying the project to the emulator, because the emulator does not have to be started first.

Deploying the MIDlet to a Nokia device

When the project is built, NetBeans creates its MIDlet Suite, consisting of a JAD file and a JAR file. These are found in the project’s /dist folder. If the Nokia PC Suite is installed on the development PC, the NetBeans deployment module can be used to deploy the application to a Nokia device connected to the PC by a Bluetooth, infrared, or USB connection.

To use this feature, the project needs to be told which deployment option to use. Do so by opening the project's properties, by selecting File -> Project Properties from the NetBeans menu. In the properties dialog, shown in the following figure, select Deploying from the Category list on the left of the display.

12 deploying.jpg

Now select Nokia Terminal connected via PC Suite as the method, and save the properties. Next, select Deploy from the project's context menu. The application will now be sent to the device connected to the PC, where it is installed in the usual way. Once installed, the application can be run in exactly the same way as it would be if it had been installed by a user.

Further information about deploying an application to a device is available here.

More information

We hope that this short introduction has shown how powerful and convenient NetBeans is for creating mobile Java applications. There is much more information on creating mobile Java applications for Nokia devices in this Wiki and on the Nokia Developer website.

You can also find out more from the NetBeans web page.

398 page views in the last 30 days.