Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 8.1 for Windows
E50624-02
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

5 About Java ME Embedded Application Projects

An Integrated Development Environment (IDE) uses projects to combine source files and settings that are necessary to build, run, and debug applications. Without an IDE, there are a lot more manual actions required to manage all the files and settings.

The development and configuration of an application in the IDE takes place in the context of the 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

http://help.eclipse.org

Managing Java ME Embedded Application Projects in NetBeans IDE

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:

  1. On the File menu, select New Project.

  2. On the Choose Project step, select Java ME Embedded from the Categories list and Java ME Embedded Application from the Projects list. Click Next.

  3. On the Name and Location step, specify initial settings as necessary and click Finish.

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:

  1. Right-click the project on the Projects tab, select New, then MIDlet.

  2. On the Name and Location step of the New MIDlet window, specify the name and location as necessary and click Finish.

To configure the settings of an existing project in NetBeans IDE, right-click the project on the Projects tab, and select Properties.

Managing Java ME Embedded Application Project Sources in NetBeans IDE

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.

Managing the List of Source Package Folders

The sources for a project are maintained in the form of a list of folders with source code files and packages. 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. If there are multiple folders used by a project, you can define the order in which folders are processed (that is, source files are compiled) using 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.

Setting the Source and Target Versions

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 -source and -target options of the javac Java compiler.

Setting the Encoding of Source Files

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.

Including and Excluding Source Files

The defined source package folders may contain files that you want to exclude from the project. To configure which files to included and exclude, click the Includes/Excludes button under the list of source package folders. Specify regular expressions to filter out files you want to include and files you want to exclude. Check the lists of included and excluded files based on the regular expressions to make sure that the expressions are correct and click OK.

Related Topics

For more information about the javac Java compiler, see the Java Platform, Standard Edition Tools Reference at

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html

Selecting Java ME Embedded Application Project Platform in NetBeans IDE

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, right-click the project, select Properties, and then open the Platform category.

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.

Managing Platforms in 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.

Configuring the Emulation Environment

The Java ME platform includes an emulation environment that provides implementations of the device's APIs. For example, Oracle Java ME SDK 8.1 includes the Java ME Embedded 8.1 runtime as an emulation environment for Windows.

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.1, EmbeddedDevice1 is selected by default.

Because Java ME Embedded 8.1 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.

Managing Java ME Embedded Application Project Libraries in NetBeans IDE

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 -classpath, -sourcepath, and -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.

Related Topics

For more information about the javac Java compiler, see the Java Platform, Standard Edition Tools Reference at

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html

Managing Java ME Embedded Application Descriptor Attributes in NetBeans IDE

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

http://docs.oracle.com/javame/config/cldc/opt-pkgs/api/meep/api/doc-files/packaging.html

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-Name, MIDlet-Vendor, and MIDlet-Version. For a LIBlet, the default attributes are LIBlet-Name, LIBlet-Vendor, and LIBlet-Version.

    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 MIDlet-Jar-URL or LIBlet-Jar-URL attribute.


    Caution:

    Attributes beginning with MIDlet-, LIBlet-, or 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

    http://docs.oracle.com/javame/config/cldc/opt-pkgs/api/meep/api/javax/microedition/io/PushRegistry.html


    Note:

    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 LIBlet-Permission-Opt-1 attribute.

    For more information about permissions, see the Security for Applications document of the Java ME Embedded Profile Specification at

    http://docs.oracle.com/javame/config/cldc/opt-pkgs/api/meep/api/doc-files/security_framework.html

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.

Configuring Java Compiler Settings in NetBeans IDE

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).

The javac command has many options that allows 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, right-click the project, select Properties, and then open the Compiling category.

Generating Debugging Information

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 javac command.

Reporting Deprecated API Usage

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.

Tracking Java Dependencies

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.

Processing Annotations

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 javac command. 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 javac command.

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, click Add next to the list, enter a key and its value, and click OK. This list defines the -A option of the javac command. It is specified in the form -Akey[=value].

Other Java Compiler Settings

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 javac command.

Related Topics

For more information about the javac Java compiler, see the Java Platform, Standard Edition Tools Reference at

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html

Signing Java ME Embedded Applications in NetBeans 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.

To enable signing for an existing Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, open the Signing category, and select Sign JAR.

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. The certificates in the built-in keystore can be used for internal testing purposes. When you are ready to distribute your application, you should buy a signing key pair from a reputable certificate authority (CA) and use it to sign the application.

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:

  1. In the Signing category of the project properties, click Export Key into Java ME SDK Platform Emulator.

    Alternatively, you can click Export in the Keystores Manager window.

  2. Select the device and one of the security clients available on the device.

  3. Click Export.

Obfuscating Java ME Embedded Applications in NetBeans 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.

To enable obfuscation for an existing Java ME Embedded Application project in NetBeans IDE, right-click the project, select Properties, open the Obfuscating category, and click Install ProGuard Obfuscator.

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

http://proguard.sourceforge.net/#manual/refcard.html

Configuring Project Documentation Settings in NetBeans IDE

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).

The 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.

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 command.

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 -notree option.

To omit the usage pages, deselect Class and Package Usage Pages. This removes the -use option from the javadoc command.

To omit the navigation bar, header and footer, deselect Navigation Bar. This starts the javadoc tool with the -nonavbar option.

To omit the index, deselect Index. This starts the javadoc tool with the -noindex option.

To generate the index on a single page, deselect Separate Index per Letter. This removes the -splitindex option from the javadoc command.

By default, Javadoc does not process the @author and @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 javadoc command.

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 javadoc command.

To open the generated Javadoc in your default browser after completion, select Preview Generated Javadoc.

Related Topics

For more information about the javadoc tool, see the Java Platform, Standard Edition Tools Reference at

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html

Configuring Java ME Embedded Emulator Settings in NetBeans IDE

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 emulator command.

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).


Note:

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 30000.

Managing Java ME Projects in Eclipse IDE

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:

  1. Ensure that the Java ME perspective is active as follows:

    1. Open the Window menu, select Open Perspective, then Other.

    2. In the Open Perspective window, select Java ME and click OK.

  2. On the File menu, select New and then Java ME Project.

  3. 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 add an IMlet to a Java ME Embedded Application project:

  1. Right-click the project on the Package Explorer tab, select New, then Java ME MIDlet.

  2. In the New Java ME MIDlet dialog, specify initial settings as necessary. You can click Next and Back to navigate the wizard. When you are done, click Finish.

It is also possible to import an existing project into Eclipse IDE as follows:

  1. Open the File menu and select Import.

  2. In the list, expand the General node and select Existing Project into Workspace. Click Next.

  3. Select the root directory of the project or an archive if you previously saved your project into an archive.

  4. Select the project name in the list and click Finish.

To configure the settings of an existing project in Eclipse IDE, right-click the project on the Package Explorer tab, and select Properties.

Managing Java ME Project Device Configurations in Eclipse IDE

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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. 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:

  1. Click Add.

  2. Select the Java ME SDK platform and device that you want to add.

  3. Optional: Specify a name for the configuration. By default, the name of the device is used.

  4. Click Finish to add the configuration to the project.

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.

Performing Code Validation for a Java ME Project in Eclipse IDE

Code validation is the process of checking that the source code of your application complies with standards and recommendations for Java. 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:

  1. Open the Window menu and select Preferences.

  2. In the left pane of the Preferences window, expand the Java ME category and select Code Validation.

  3. 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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Code Validation category under Java ME.

  3. Select Enable project specific settings.

  4. Select the language constructs that you would like to be warned about or that you want to ignore when compiling.

Managing Java ME Project Libraries 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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Library category under Java ME.

  3. 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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, expand the Java Build Path category and select LIBlets.

  3. Click Add and configure the LIBlets that you want to add to the project build path.

Obfuscating Java ME Embedded Applications 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:

  1. Open the Window menu and select Preferences.

  2. In the left pane of the Preferences window, expand the Java ME category, then expand Packaging, and select Obfuscation.

  3. 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.

  4. 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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Obfuscation category under Java ME.

  3. Select Enable project specific settings.

  4. 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.

  5. 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.

For more information about command-line options of ProGuard, see the ProGuard Reference Card at

http://proguard.sourceforge.net/#manual/refcard.html

Setting Java ME Project Packaging Attributes in Eclipse IDE

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:

  1. Open the Window menu and select Preferences.

  2. In the left pane of the Preferences window, expand the Java ME category and select Packaging.

  3. 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).

  4. 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. Double-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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Packaging category under Java ME.

  3. Select Enable project specific settings.

  4. If you want the version to automatically increment every time you build the project, select Increment Version Automatically. This option sets the MIDlet-Version attribute (or LIBlet-Version if you are building a LIBlet).

  5. 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. Double-click existing attributes to modify them. Select an attribute and click Remove to remove it from the list.

Configuring Source Code Preprocessor for Java ME Projects in Eclipse IDE

Preprocessing enables you to perform build-time source code transformations to deal with device fragmentation. Devices have different constraints and inconsistencies that require a developer to use preprocessing rather than create an application that can deal with this at runtime.

Preprocessor 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 preprocessor settings for all projects in Eclipse IDE:

  1. Open the Window menu and select Preferences.

  2. In the left pane of the Preferences window, expand the Java ME category and select Preprocessor.

  3. Select the debug level for the preprocessor to include during build time.

To configure project-specific preprocessor settings for an existing Java ME project in Eclipse IDE:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Preprocessor category under Java ME.

  3. Select Enable project specific settings.

  4. Select the debug level for the preprocessor to include during build time.

Signing Java ME Embedded Applications 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:

  1. Open the Window menu and select Preferences.

  2. In the left pane of the Preferences window, expand the Java ME category and select Signing.

  3. Specify the location of the key store.

  4. Select whether you want to enter the password when it is required or save it in the current Eclipse IDE workspace keyring.

  5. 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.

  6. 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:

  1. Right-click the project on the Package Explorer tab, and select Properties.

  2. In the left pane of the Properties window, select the Signing category under Java ME.

  3. Select Enable project specific settings.

  4. Specify the location of the key store.

  5. Select whether you want to enter the password when it is required, save it in the current Eclipse IDE workspace keyring, or save it as part of the project.

  6. 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.

  7. If you do not want to use Java defaults, configure additional settings under Advanced Settings.