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
http://docs.oracle.com/cd/E50453_01/doc.80/e50452/toc.htm
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.
Eclipse IDE with Mobile Tools for Java (MTJ) extensions includes a project type that is preconfigured for developing Java ME Embedded applications. The project defines settings that are specific to Java ME Embedded.
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 project in Eclipse IDE:
Ensure that the Java ME perspective is active as follows:
Open the Window menu, select Perspective, select Open Perspective, and then Other.
In the Open Perspective window, select Java ME and click OK.
On the File menu, select New and then Java ME Project.
In the New Java ME Project dialog, specify initial settings as necessary. You can click Next and Back to navigate the wizard. When you are done, click Finish.
When you create a project in Eclipse IDE, you can view it in one of two ways:
The Package Explorer tab provides a logical view of the project
The Navigator tab provides a physical view of the project
To configure the settings of an existing project in Eclipse IDE, right-click the project on the Package Explorer tab, and select Properties.
To add an IMlet to a Java ME Embedded Application project:
To configure the settings of an existing project in Eclipse IDE, right-click the project on the Package Explorer tab, and select Properties.
To import an existing project into Eclipse IDE:
To configure the settings of an existing project in Eclipse IDE, right-click the project on the Package Explorer tab, and select Properties.
The Java ME Embedded platform included with Oracle Java ME SDK provides an emulation environment for Windows to run Java ME Embedded applications on an emulated device.
To manage the device configurations on which you want to run the project:
Right-click the project on the Package Explorer tab, and select Properties.
In the left pane of the Properties window, select the Java ME category.
The Configurations list contains a list of devices that are available to the project.
To add a device to the Configurations list:
To edit the configuration, select it in the list and click Edit. To remove a configuration from the project, select it in the list and click Remove.
Below the configuration list, you can specify names of generated JAR and JAD files.
Code validation is the process of checking that the source code of your application complies with standards and recommendations for Java ME. Clean sources can help you maintain your code base efficiently.
Code validation settings in Eclipse IDE are configured globally (for all projects), but you can also override some of the settings for a specific project. To configure global code validation settings for all projects in Eclipse IDE:
Open the Window menu and select Preferences.
In the left pane of the Preferences window, expand the Java ME category and select Code Validation.
Select the language constructs that you would like to be warned about or that you want to ignore when compiling.
To configure project-specific code validation settings for an existing Java ME project in Eclipse IDE:
A project may depend on external libraries of classes and source files. These dependencies are added to the class path so that they can be accessed during compilation and included into the JAR file. The list of libraries defines the -classpath
option of the javac
Java compiler.
To manage these libraries for an existing Java ME project in Eclipse IDE:
Right-click the project on the Package Explorer tab, and select Properties.
In the left pane of the Properties window, select the Library category under Java ME.
Select the libraries to be included from the list of available libraries.
Java ME Embedded applications may use LIBlets, which are a special type of shareable software components used at runtime. To add LIBlets to a Java ME project in Eclipse IDE:
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.
Obfuscation settings in Eclipse IDE are configured globally (for all projects), but you can also override some of the settings for a specific project. To configure global obfuscation settings for all projects in Eclipse IDE:
Open the Window menu and select Preferences.
In the left pane of the Preferences window, expand the Java ME category, then expand Packaging, and select Obfuscation.
If you want to set command-line options for running ProGuard, select Use specified arguments and enter the options in the field that follows the check box.
You can use the Proguard Keep Expressions list to define the list of classes and class members to be preserved as entry points to the application. By default, all public classes that extend the javax.microedition.midlet.MIDlet
class are preserved from obfuscation. Click Add to add more regular expressions to the list. Double-click existing expressions to modify them. Select an expression and click Remove to remove it from the list.
To configure project-specific obfuscation settings for an existing Java ME project in Eclipse IDE:
javax.microedition.midlet.MIDlet
class are preserved from obfuscation. Click Add to add more regular expressions to the list. Double-click existing expressions to modify them. Select an expression and click Remove to remove it from the list.For more information about command-line options of ProGuard, see the ProGuard Reference Card at
Java ME Embedded applications are packaged into JAR files with corresponding descriptor JAD files. The manifest in the JAR and the JAD file contain attributes that describe the application.
Packaging settings in Eclipse IDE are configured globally (for all projects), but you can also override some of the settings for a specific project. To configure global packaging settings for all projects in Eclipse IDE:
Open the Window menu and select Preferences.
In the left pane of the Preferences window, expand the Java ME category and select Packaging.
If you want the version to automatically increment every time you build a project, select Increment Version Automatically. This option sets the MIDlet-Version
attribute (or LIBlet-Version
if you are building a LIBlet).
You can use the Excluded Manifest Entries list to define the list of attributes that should be excluded from the manifest. By default, the following attributes are excluded:
MIDlet-Jar-URL
: Points to the location of the JAR file.
MIDlet-Jar-Size
: Specifies the size of the JAR file.
LIBlet-Jar-URL
: Points to the location of the JAR file.
LIBlet-Jar-Size
: Specifies the size of the JAR file.
Click Add to add more attributes to the list. Click existing attributes to modify them. Select an attribute and click Remove to remove it from the list.
To configure project-specific packaging attributes for an existing Java ME project in Eclipse IDE:
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. Security aware vendors always have more credibility in the industry.
Signing in Eclipse IDE is configured globally (for all projects), but you can also override some of the settings for a specific project. To configure global signing settings for all projects in Eclipse IDE:
Open the Window menu and select Preferences.
In the left pane of the Preferences window, expand the Java ME category and select Signing.
Specify the location of the key store.
Select whether you want to enter the password when it is required or save it in the current Eclipse IDE workspace keyring.
To create a new key pair in the specified key store, click Create New Key Pair to the right of the Key Aliases list.
To remove a key pair from the key store, select it in the list and click Delete Entry.
To import a certificate from a certificate authority (CA), click Import Certificate.
To import a response to your certificate signing request (CSR), click Import CSR Response.
If you do not want to use Java defaults, configure additional settings under Advanced Settings.
To configure project-specific signing settings for an existing Java ME project in Eclipse IDE:
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 Eclipse 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.