The chapter contains the following topis:
The development and configuration of an application in the IDE takes place in the context of a project. It is the highest level of organization for the application that you are developing.
When you create a project in an IDE, it generates an Ant script to build the application. Alternatively, IDEs also support Maven. For more information about Ant and Maven, see their respective official web sites:
For more information about NetBeans IDE projects, see Developing Applications with NetBeans IDE at
For more information about Eclipse IDE projects, see Eclipse Documentation at
NetBeans IDE includes various project types that are preconfigured for developing Java SE, JavaFX, Java ME, and many other types of applications. Each type includes template source files and settings that are specific to the development platform.
You can initially define some of the more important settings when the project is created. Other settings are preconfigured with default values, however, you can change them at any time.
To create a Java ME Embedded Application project in NetBeans IDE:
When you create a project in NetBeans IDE, you can view it in one of two ways:
The Projects tab provides a logical view of the project
The Files tab provides a physical view of the project
To rename, move, copy, or delete an existing project in NetBeans IDE, right-click the project on the Projects tab, and select Rename, Move, Copy, or Delete.
To add an IMlet to a Java ME Embedded Application project:
To configure the settings of an existing project in NetBeans IDE, right-click the project on the Projects tab, and select Properties.
When creating a project in NetBeans IDE, you specify the location and name of the project folder. By default, the
src folder is created inside the project folder for all source packages. You can add other folders with source code files and packages that you want to be part of the project.
To manage the project sources in NetBeans IDE, right-click the project, select Properties, and then open the Sources category.
The sources for a project are maintained in the form of a list of folders with source code files and packages. The order of the folders in the list defines the order in which the folders are processed (that is, source files are compiled).
To add a folder with sources that you want to be part of the project, click Add Folder.
To remove a folder, select it in the list and click Remove.
To define the order in which folders are processed, use the Move Up and Move Down buttons.
For each source package folder, you can define a label that is displayed in the Projects view. For example, the default
src folder is labeled
Source Packages. By default, all added folders are labeled with the name of the folder. To change a label, double-click it, enter a name, and press Enter.
If you are developing an application that must be compatible with previous versions of Java, you can set the version of the source code that the compiler should expect, and the target runtime version for which you want to compile.
To set the source and target version:
Select it in the Source/Binary Format drop-down list under the list of source package folders.
This setting defines the
-target options of the
javac Java compiler.
If development occurs in multiple countries, encoding of source files in projects may vary. You need to make sure that the Java compiler knows the encoding.
To set the encoding of source files in a project:
Select it in the Encoding drop-down list under the list of source package folders.
This setting defines the
-encoding option of the
javac Java compiler.
The defined source package folders may contain files that you want to exclude from the project.
To configure which files to included and exclude:
The Java SE Development Kit (JDK) is used to compile and package a Java ME Embedded application, while the Java ME Embedded platform included with Oracle Java ME SDK provides an emulation environment for Windows to run the application on an emulated device.
You can select both the JDK and the Java ME platform for a Java ME Embedded Application project when creating the project. To select the JDK and the Java ME platform for an existing Java ME Embedded Application project:
The JDK Path and Java ME Platform drop-down lists contain only those JDK versions and Java ME platforms that are registered with NetBeans IDE.
When you install NetBeans IDE, it automatically detects and registers all Java platforms on your computer. You can use the Java Platform Manager to manually register other platforms in NetBeans IDE as necessary. To access the Java Platform Manager do one of the following:
On the Tools menu, select Java Platforms.
When creating a project, click Manage Platforms.
In the Platform category of the Project Properties window for an existing project, click Manage Platforms.
The Java ME platform includes an emulation environment that provides implementations of the device's APIs. For example, Oracle Java ME SDK8.3 includes the Java ME Embedded 8.3 runtime as an emulation environment for Windows and Linux.
To select the default device on which to run the Java ME Embedded Application project, use the Device drop-down list. In case of Oracle Java ME SDK 8.3,
EmbeddedDevice1 is selected by default.
Because Java ME Embedded 8.3 implements only JSR 360: Connected Limited Device Configuration 8 (CLDC 8) and JSR 361: Java ME Embedded Profile (MEEP 8), the Configuration and Profile options do not provide any alternatives.
Various devices may implement optional application programming interfaces (APIs) to provide specific functionality (for example, wireless communication or physical location tracking). By default, all optional packages available to the platform are selected for a project. However, if a device does not support some of the APIs, you can exclude corresponding packages to reduce the size of the application.
A project may depend on classes, associated source files, annotation processors, and Javadoc documentation from another project, library, Java Archive (JAR), or any other location. These dependencies (also known as libraries) are added to the class path so that they can be accessed during compilation. The list of libraries defines the
-processorpath options of the
javac Java compiler.
To manage these libraries for an existing Java ME Embedded Application project, right-click the project, select Properties, and then open the Libraries category. The following tabs are available in the Libraries category:
Compile: This tab is used to manage the list of compile-time libraries that define the location of general dependencies required during compilation. These are propagated to other library types.
Processor: This tab is used to manage the list of processor-path libraries that define the location of the annotation processors used in the project. If no libraries are specified or the processor is not available in the specified libraries, then the general compile-time class path is searched for annotation processors.
LIBlets: This tab is used to manage the list of shareable software components that a Java ME Embedded application may use at runtime. To customize LIBlet-specific options in this tab, add LIBlets of type
liblet as compile-time libraries on the Compile tab.
A project can have dependencies in another project, in a library, in a JAR file, or in a folder. To add the dependency, click the corresponding button (Add Project, Add Library, or Add JAR/Folder).
To edit a library, select it in the list and click Edit. To remove a library, select it in the list and click Remove. If there are multiple libraries on which a project depends, you can define the order in which they are searched for the corresponding dependencies using the Move Up and Move Down buttons.
If there are source code files in the libraries that are associated with a project, they have to be built to be used. The Build Projects on Classpath check box is selected by default to enable all project dependencies to be built if they are on the class path. If you know that your project does not require any of the source files in the dependent libraries, you can deselect this check box to decrease the time of compilation.
For more information about the
javac Java compiler, see the Java Platform, Standard Edition Tools Reference at
The basic components of a Java ME Embedded application are the Java Application Descriptor (JAD) file and the Java Archive (JAR) file. Together, these two files form an IMlet suite. Application descriptor attributes define metadata that represents the application's properties and configuration.
Attributes are contained in a JAD file, and include information, such as the name, vendor, and version of the IMlet suite, the location and size of the JAR file, and the configuration and profile requirements. The JAD file may contain any number of attributes defined by JSR 361: Java ME Embedded Profile (MEEP 8), as well as custom attributes defined by the developer of the application.
A manifest file contained in a JAR file has the same syntax as the JAD file and it may share the same attributes. Attributes in the JAD file must agree with those in the manifest file.
For more information about the application descriptor attributes, see the Application Packaging document of the Java ME Embedded Profile Specification at
To manage application descriptor attributes for an existing Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, and then open the Application Descriptor category. The following tabs are available in the Application Descriptor category:
Attributes: This tab is used to manage the list of name and value pairs for general attributes. If you are creating a Java ME Embedded application, select MIDlet Suite as the packaging model. If you are creating a shareable software component that an application will use during runtime, select LIBlet as the packaging model.
There are three default attributes defined that are required and cannot be removed from the list. For a MIDlet, the default attributes are
MIDlet-Version. For a LIBlet, the default attributes are
By default, the JAR file is located in the same folder as the JAD file. To specify a different location for the JAR file that is specified in the JAD file, select Override JAR URL in JAD under the list of general attributes, and enter an absolute or relative URL that will be used as the value for the
Attributes beginning with
MicroEdition- are reserved for use by the application management software (AMS) on the device. Do not use these for custom user-defined attributes!
MIDlets: This tab is used to manage the list of MIDlets in the suite, with a class name, a displayed name, and a displayed icon for each. At least one entry is necessary. By default, it is the main IMlet class.
The first entry in the list defines the
MIDlet-1 attribute, the second entry defines the
MIDlet-2 attribute, and so on. You can change the order using the Move Up and Move Down buttons.
Push Registry: This tab is used to manage the list of MIDlets that are registered for push notifications, with a class name, an IP address of the sender, and a connection string that identifies the protocol and port number. When you install your application on a device, the application management software (AMS) listens for incoming connections from MIDlets specified in the push registry. If a registered MIDlet connects from a matching IP address over the specified protocol to the specified port number, the AMS launches the application.
The first entry in the list defines the
MIDlet-Push-1 attribute, the second entry defines the
MIDlet-Push-2 attribute, and so on. You can change the order using the Move Up and Move Down buttons.
For more information about the push registry, see the Javadoc for the
javax.microedition.io.PushRegistry class in the Java ME Embedded Profile Specification at
To use the push registry in your application, you must set the
javax.microedition.io.PushRegistryPermission attribute on the API Permissions tab.
API Permissions: This tab is used to manage the list of permission attributes for protected APIs that the application uses. When you install your application on a device, the AMS compares the permissions requested with the permissions in the destination protection domain. If a required permission is denied, the installation terminates and an exception is returned. If an optional permission is denied, the application may install, but will run with limited functionality.
For a MIDlet, the first required permission entry in the list defines the
MIDlet-Permission-1 attribute, the second required permission entry defines the
MIDlet-Permission-2 attribute, and so on. Optional permission entries define the
MIDlet-Permission-Opt-1 attribute, the
MIDlet-Permission-Opt-2 attribute, and so on. For a LIBlet, corresponding attributes begin with the
LIBlet-Permission-1 attribute and the
For more information about permissions, see the Security for Applications document of the Java ME Embedded Profile Specification at
On each tab, to add an attribute, click Add, provide the necessary data, and click OK. To edit an attribute, select it and click Edit. To remove an attribute, select it and click Remove.
When building a Java ME Embedded Application project, NetBeans IDE automatically compiles the main IMlet class and any other necessary classes. To do this, NetBeans IDE uses the
javac Java compiler from the Java SE Development Kit (JDK).
javac command has many options that allow you to configure how the Java compiler produces bytecode class files. These options can be configured in the NetBeans IDE project properties.
To configure Java compiler settings for an existing Java ME Embedded Application project in NetBeans IDE:
The Java compiler can generate debugging information into the output class files. This information can then be used by debugging tools during run time.
By default, a project is configured to generate all debugging information, which is defined by the
-g option of the
javac command. This includes information about line numbers, source files, and local variables. However, once your application is fully debugged, you should recompile it without any debugging information to make the class files smaller and harder to reverse engineer.
To build your project without any debugging information:
Deselect Generate Debugging Info.
This sets the
-g:none option for the
As Java classes are updated, their APIs change. New methods, constructors, and fields are added, existing ones can sometimes be renamed for consistency. Some classes and interfaces can replace existing ones when a better approach is found.
Java supports a deprecation mechanism to let the developers know when an API they are using is deprecated. To deprecate a class, method, or member field, an annotation is added to it, as well as a Javadoc tag with comments. The comment is generated in the Javadoc for the API, warning the user and suggesting alternatives. The annotation causes the
javac Java compiler to produce a warning, although existing calls to deprecated APIs continue to work, and classes are still compiled.
To see the exact class, method, or member field that is deprecated:
Select Report Uses of Deprecated APIs.
This behavior is defined by the
-deprecation option of the
javac command. Without this option, the Java compiler shows only a summary of the source file names that use or override deprecated classes, methods, or fields.
If your project depends on external classes, it is important to track modifications to the dependencies. The ability to track this is a feature of the build system used by NetBeans IDE.
To automatically recompile any class in your project that depends on a class that has been modified:
Select Track Java Dependencies.
This ensures that the latest version of any project dependency is used by NetBeans IDE when you build and run the project.
Annotations are metadata in the source code that provide information about the code and do not affect the operation of the application. Some annotations are used by the Java compiler to detect errors or suppress warnings. Other annotations are processed at the beginning of compilation to generate additional source code files, XML files, and so on. And there are certain annotations that are accessible at run time.
To enable annotation processing during compilation:
Select Enable Annotation Processing
This is the default behavior of the Java compiler.
If you deselect this option, annotations will not be processed, which is defined by the
-proc:none option of the
To see the results of annotation processing directly in the Java Editor in NetBeans IDE:
select Enable Annotation Processing in Editor.
You can specify custom annotation processors that you want to use for building your project in the Annotation Processors list.
To add a processor:
Click Add next to the list.
Enter the fully qualified name (FQN) of the processor and click OK.
This list defines the
-processor option of the
If the annotation processor associated with your project excepts command-line options, you can specify the ones that you want to pass to it in the Processor Options list.
To add an option:
This list defines the
-A option of the
javac command. It is specified in the form
To configure additional Java compiler settings, enter the corresponding
javac command options in the Additional Compiler Options field. Use the exact syntax that you would use when entering them after the
Signing a Java ME Embedded application allows MEEP devices to verify the integrity and origin of the IMlet suite. Signing information is used to check an application's source and validity before allowing it to access certain protected APIs. The certificate that is used to sign your application designates a security domain that defines the permitted protected APIs.
You should sign your applications for security reasons, to protect them from being tampered by malicious third parties, and to increase their acceptance by distribution channels.
Oracle Java ME SDK provides a built-in keystore whose certificates can be used for testing purposes. When you are ready to distribute your application, you should buy a signing key pair from a reputable certificate authority (CA), import it to a keystore and use it to sign the application. Note that the certificate must be registered on a device.
To sign a Java ME Embedded Application project in NetBeans IDE:
By default, the built-in keystore provided by Oracle Java ME SDK is selected, with the
minimal certificate, which denies all permissions to protected APIs.
To be able to select a non-default key pair with which to sign your application, import it to an existing keystore or create a new keystore. This can be done in the Keystores Manager.
To open the Keystores Manager window, click Open Keystores Manager.
Besides selecting the certificate for signing your application, you have to make sure that the corresponding key is registered on the device.
To export the selected key to a specific device registered with Oracle Java ME SDK:
Alternatively, you can click Export in the Keystores Manager window.
Obfuscation refers to deliberately making program code harder to understand, decompile, and reverse-engineer. Obfuscators are programs that transform readable code into obfuscated code.
Oracle Java ME SDK includes ProGuard, which is a Java bytecode obfuscator. It first shrinks, optimizes, and preverifies Java class files to make them more compact. Then it transforms the bytecode to make it almost impossible to reverse-engineer. This is an important security measure, because raw bytecode produced by the Java compiler contains much of the source code information, which is your intellectual property. Size optimization is also crucial for Java ME Embedded applications, which are designed for resource-constrained devices.
To enable obfuscation for an existing Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, open Obfuscating under the Build category, and click Install ProGuard Obfuscator.
If you can't install ProGuard Obfuscator, ensure that your computer is online, all servers in the Update Center are checked, and proxy settings are set as required.
When ProGuard is installed, select the level of obfuscation using the Obfuscation Level slider. You can see the impact of the selected obfuscation level on bytecode in the Level Description field. This field also lists the arguments passed to ProGuard when it is launched. To configure additional settings for ProGuard, specify the corresponding options in the Additional Obfuscation Settings field.
For more information about command-line options of ProGuard, see the ProGuard Reference Card at
For each of your applications, you can produce a set of Javadoc HTML pages that describe the project's classes, inner classes, interfaces, constructors, methods, and fields. The Javadoc is constructed from the structure of your code and the Javadoc comments embedded in your code. To do this, NetBeans IDE uses the
javadoc tool from the Java SE Development Kit (JDK).
javadoc command has many options that allows you to configure how Javadoc files are produced, what information they include, and so on. These options can be configured in the NetBeans IDE project properties.
To configure Javadoc settings for an existing Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, and then open the Documenting category under the Build category.
By default, Javadoc generates documentation only for protected and public classes and members. If you want to document all classes and members, including those with the private and package-private access levels, select Include Private and Package Private Members. This behavior is defined by the
-private option of the
Javadoc can generate some additional pages to aid with navigation. By default, NetBeans IDE is configured to generate the class hierarchy tree pages, the class and package usage pages, the navigation bar, and index with a separate page for each letter.
To omit the class hierarchy tree pages, deselect Class Hierarchy Tree. This starts the
javadoc tool with the
To omit the usage pages, deselect Class and Package Usage Pages. This removes the
-use option from the
To omit the navigation bar, header and footer, deselect Navigation BarNavigation Bar. This starts the
javadoc tool with the
To omit the index, deselect Index. This starts the
javadoc tool with the
To generate the index on a single page, deselect Separate Index per Letter. This removes the
-splitindex option from the
By default, Javadoc does not process the
@version tags. To include information about the author or version, select the corresponding check box under Document Additional Tags. This is defined by the
-tag option of the
To set the browser window title (that is, the
<title> tag in the HTML code of the generated pages), enter it in the Browser Window Title field. This is defined by the
-windowtitle option of the
javadoc command. If the window title is not set explicitly, the value of the
-doctitle option is used, which is by default set to the name of the NetBeans IDE project.
To configure additional Javadoc tool settings, enter the corresponding
javadoc command options in the Additional Javadoc Options field. Use the exact syntax that you would use when entering them after the
To open the generated Javadoc in your default browser after completion, select Preview Generated Javadoc.
For more information about the
javadoc tool, see the Java Platform, Standard Edition Tools Reference at
After the project is built, you can use NetBeans IDE to run your Java ME Embedded application. The Java ME Embedded Emulator is used to install and start the IMlet suite on the device.
To configure settings for running your Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, and then open the Run category.
To configure the Java ME Embedded Emulator settings, enter the corresponding options in the Emulator Command Line Options field. Use the exact syntax that you would use when entering them after the
By default, Regular Execution is selected under Run Method. This option means that the IMlet suite is executed on the device. To simulate the process of deploying the application from a server to a remote device, select Execute through OTA. This option means that only the JAD file is executed and the JAR is provisioned over the air (OTA).
When debugging, the application is always executed regularly, no OTA is used.
To set the delay for which NetBeans IDE should wait before attaching a debugger, enter a value in milliseconds in the Debugger timeout field. By default, this value is
Oracle Java ME SDK supports export of a Java ME Embedded project to a standalone Ant, Gradle, or Maven project to enable further building of the Java ME Embedded project without use of an IDE.
The exported project contains the source code for the Java ME Embedded application, build scripts, and build configuration. Note that the exported project provides only building and cleaning capabilities.
In NetBeans IDE, you can export a Java ME Embedded project to a standalone Ant, Gradle, or Maven project to enable further building of the Java ME Embedded project without use of an IDE.
In the Repository URL text field, specify the URL for the Java ME libraries.
In the Maven ant tasks path text field, which is available only for the Ant project, specify the path to the Maven ant tasks.