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

Previous
Previous
 
Next
Next
 

7 Viewing and Editing Project Properties

All projects have properties. Some properties, such as the project's name and location cannot be changed, but other properties can be edited.

To view or edit a project's properties, right-click the project node and select Properties. In the Project Properties window, you can view and customize the project properties.

Configuring Project Sources

Use the Sources category in the Project Properties window to view the project folder location and configure a list of source folders with the corresponding labels used in the Projects view.

You can add and remove folders to the list of sources, and order the list.

Below the list, use the drop-down lists to select the source format and encoding.

Selecting the Platform for the Project

The Java ME platform emulates the execution of an application on one or more target devices. Use the Platform category in the Project Properties window to select and configure the platform used in your project.

Ensure that Oracle Java Platform Micro Edition SDK 8.0 is selected as the platform.

By default, the devices in the device menu are also suitable for the platform type and emulator platform. The device you select is the default device for this project. It is used whenever you run the project. The selected device influences the device's Configuration and Profile options, and the available optional packages.

Configuring Project Libraries

Use the Libraries category in the Project Properties window to configure the list of libraries used for compiling, running, and testing the project.

You can add, edit, and remove projects, libraries, JAR files, and folders to the lists in corresponding tabs. You an also reorder the lists as required.

Configuring Application Descriptor Attributes

Use the Application Descriptor category in the Project Properties window to configure the project attributes.

Under each tab, you can add, edit, remove, and reorder the general attributes for JAR manifests, MIDlets in the suite, the push registry, and permissions requested by the API.


Note:

Do not begin user-defined attribute keys with MIDlet- or MicroEdition-.

To use the push registry, you must configure the permission to access the Push Registry API (javax.microedition.io.PushRegistry) in the API Permissions tab.


Configuring the Build Process

When you build a project, the Oracle Java ME SDK 8 compiles the source files and generates the packaged build output (a JAR file) for your project. You can build the main project and all of its required projects, or build any project individually.

In general, you do not need to build the project or compile individual classes to run the project. Use the Build category and its subcategories in the Project Properties window to configure the following build tasks:

Configuring Project Running Properties

Use the Run category in the Project Properties window to set up the configuration for running the project.

You can set command-line options, the debugger timeout, and the run method.

Building a Project from the Command Line

In NetBeans IDE, you click one button to build and run the project. Behind the scenes, however, there are two steps. First, Java source files are compiled into Java class files. Next, the class files are preverified, which means they are prepared for the CLDC virtual machine.

To build the project manually from the command line, do the following:

  1. Run the jar command to verify that it is in your PATH environment variable.

    Check the version of the JDK by running java -version on the command line.

  2. Use the javac compiler from the JDK to compile the source files. You can use the existing Oracle Java ME SDK 8 project directory structure. Use the -bootclasspath option to tell the compiler to use the MEEP APIs, and use the -d option to tell the compiler where to put the compiled class files.

    The following example demonstrates how you might compile an application, taking source files from the src directory and placing the class files in the tmpclasses directory:

    C:\> javac -bootclasspath ..\..\lib\cldc_1.8.jar;..\..\lib\meep_8.0.jar
         -d tmpclasses
         src\*.java
    

    For more information about javac, see the JDK Command Reference.

Packaging an IMlet Suite (JAR and JAD)

To package an IMlet suite manually, you must create a manifest file, an application JAR file, and an IMlet descriptor (also known as a Java Application Descriptor or JAD).

Create a manifest file that contains the appropriate attributes as specified in the MEEP specification. You can use any text editor to create the manifest file. For example, a manifest might have the following contents:

MIDlet-1: My MIDlet, MyMIDlet.png, MyMIDlet
MIDlet-Name: MyMIDlet
MIDlet-Vendor: My Organization
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.8
MicroEdition-Profile: MEEP 8.0

Create a JAR file that contains the manifest and the suite's classes and resource files. To create the JAR file, use the jar tool that comes with the Java SE software development kit. The syntax is as follows:

jar cfm file manifest -C class-directory . -C resource-directory .

The arguments are as follows:

For example, to create a JAR file named MyApp.jar whose classes are in the classes directory and resources are in the res directory, use the following command:

jar cfm MyApp.jar MANIFEST.MF -C classes . -C res .

Create a JAD file that contains the appropriate attributes as specified in the MEEP specification. You can use any text editor to create the JAD file. This file must have the extension .jad.


Note:

You must set the MIDlet-Jar-Size entry to the size in bytes of the JAR file created in the previous step.


For example, a JAD file might have the following contents:

MIDlet-Name: MyIMlet
MIDlet-Vendor: My Organization
MIDlet-Version: 1.0
MIDlet-Jar-URL: MyApp.jar
MIDlet-Jar-Size: 24601