Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.2 for Windows
E24265-04
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

5 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 freely edited as work on your project progresses. To view or edit a project's properties, right-click the project node and select Properties. In the resulting window, you can view and customize the project properties. See the following topics:

5.1 General Project Properties

To view the General property page, right-click on a project, choose Properties, and select the General category. The general properties page displays basic project properties. You can set application versioning here, but all other values cannot be edited.

The project name, folder, and source location are set when the project is created. The Application Version Number field displays the version number of the current build.

Application Versioning

The Application Version Counter field displays the next version number to be used. The default advance is 0.0.1. To advance the number beyond this, use the dropdown menu to select a new digit, or enter the value into the field. For example, changing the value to 3 results in a build number of 0.0.3. Changing the value to 100 results in the version number 0.1.0.

Required Projects

This area displays projects you have added to this project. It might be a dependent project or an external library. See Section 5.4.3, "Adding Libraries and Resources".

5.2 Platform Selection

An emulator platform simulates the execution of an application on one or more target devices. To view this property page, right-click on a project and choose Properties and select the Platform category.

Select a platform type from the dropdown menu.

For the emulator platform, be sure to select the 3.2 platform. You might have to use the dropdown menu to ensure the right version is selected.

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 use the Run command. Your device selection influences the Device Configuration and Device Profile options, and the available optional packages.

Be sure that a Device Profile is selected, and select the optional packages you want to include in this project. The selected APIs are automatically added to the project's classpath. See Section 4.2.1, "Create a CLDC Project".

5.3 Editing Application Descriptor Properties

To view this property page, right-click on a project, choose Properties, and select the Application Descriptor category. The Application Descriptor properties page enables adding, editing, or deleting project attributes.

5.3.1 CDC Attributes

To view this property page, right-click on a CDC project and choose Properties. Select the Application Descriptor category.

Application Name. The display name of the application on the target device.

ApplicationVendor. The company name or author name for the application.

Description. A concise description of the application.

Detail Description. A detailed description of the application.

5.3.2 MIDP Attributes

To view this property page, right-click on a MIDP project and choose Properties. Select the Application Descriptor category, and select the Attributes tab.

The General Attributes table lists the attributes currently contained in the JAD and JAR manifest files:

Type. Lists whether the attribute is required or optional. Custom attributes for passing parameters to the MIDlet using the JAD are also available.

Name. The name of the attribute.

Value. The values for each attribute.

To avoid errors in verification:

  • Define all required attributes.

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

5.3.2.1 Add an Attribute

Follow these steps to add an attribute.

  1. Click Add... to open the Add Attribute window.

  2. Choose an attribute from the Name combo box, or delete the current entry and add your own custom entry.


    Note:

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


  3. Enter a value for the attribute.

  4. Click OK.

5.3.2.2 Edit an Attribute

  1. Select an attribute.

  2. Click Edit... to open the Edit Attribute window.

  3. Enter a value for the attribute.

  4. Click OK.

API permissions, Push Registry Entries, and API Permissions have their own property pages.

5.3.2.3 Remove an Attribute

Select an Attribute and click Remove to delete it from the list.

5.3.3 MIDlets

To view this page, right-click on a project and choose Properties. Select the Application Descriptor category, and select the MIDlets tab.

The MIDlets table lists the MIDlets contained in the suite and the following properties:

Name. The displayable name of the MIDlet that the user sees when the MIDlet is run on a mobile device.

Class. The Java class for the MIDlet.

Icon. An icon (a .png file), representing the MIDlet that the user sees when the MIDlet is run on a mobile device.

5.3.3.1 Add a MIDlet

  1. Click Add... to open the Add MIDlet window.

    The window lists the MIDLets available in the project.

  2. Enter a name, then select a MIDlet class from the dropdown menu.

    You can also choose an icon for the MIDlet from the MIDlet icon dropdown menu.

  3. Click OK.

5.3.3.2 Edit a MIDlet

  1. Select a MIDlet.

  2. Click Edit... to open the Edit MIDlet window.

  3. Enter a value for the attribute.

  4. Click OK. The revised values are listed in the table.

5.3.3.3 Remove a MIDlet

Select a MIDlet and click Remove to delete it from the list.

5.3.3.4 Change MIDlet Display Order

The list order determines the order in which the MIDlets are displayed.

Select a MIDLet and select Move Up or Move Down to change its position.

5.3.4 Push Registry

To view this page, right-click on a project and choose Properties. Select the Application Descriptor category, and select the Push Registry tab.

See also Section 5.3.4.1, "Add a Push Registry Entry", Section 5.3.4.2, "Enabling a Push Registry Entry", Section 5.3.4.3, "Remove a Push Registry Entry", and Section 5.3.4.4, "Change Push Registry Display Order".

5.3.4.1 Add a Push Registry Entry

  1. Click Add... to open the Add Push Registry window.

  2. Enter Class Name, Sender IP, and Connection String values.

    • Class Name. The MIDlet's class name.

    • Sender IP. A valid sender that can launch the associated MIDlet. If the value is the wildcard (*), connections from any source are accepted. If datagram or socket connections are used, the value of Allowed Sender can be a numeric IP address.

    • Connection String. A connection string that identifies the connection protocol and port number.

  3. Click OK.

    The new values are listed in the table. A push registration key is automatically generated and shown as an attribute in the MIDlet suite's Java Application Descriptor (JAD) file.

5.3.4.2 Enabling a Push Registry Entry

To make use of the Push Registry, you must also have permission to access the Push Registry API, javax.microedition.io.PushRegistry. API permission, are handled in the API Permissions property page (Section 5.3.5, "API Permissions").

5.3.4.3 Remove a Push Registry Entry

Select an entry and click Remove to delete it from the list.

5.3.4.4 Change Push Registry Display Order

The list order determines the order in which the MIDlets are displayed. Select an entry and select Move Up or Move Down to change its position.

5.3.5 API Permissions

These properties set permission attributes for protected APIs called by the MIDlet suite. To view this property page, right-click on a project and choose API Permissions. Select the Application Descriptor category, and select the Attributes tab.

See Section 5.3.5.1, "Adding Permission Requests".

5.3.5.1 Adding Permission Requests

  1. Click the Add Button.

    The API Permission for API dialog opens.

  2. Choose an API from the dropdown list or enter an API into the combo box and click OK.

  3. (Optional) In the Requested Permissions table, check the Required box if you want installation to fail when that permission cannot be granted.

For more information, see Security for MIDP Applications in the MIDP 2.0 (JSR 118) specification, available at: http://developers.sun.com/techtopics/mobility/midp/articles/pushreg/.

5.4 Building a Project

When you build a project, the SDK 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. By default, the SDK automatically compiles classes when you save them. You can use properties to modify the following build tasks:

5.4.1 Configuring Ant

To view this form, select Tools > Options, select Miscellaneous, and click the Ant tab.

Ant Home. The installation directory of the Ant executable the SDK uses. To change Ant versions, type the full path to a new Ant installation directory in this field or click Browse to find the location. You can only switch between versions 1.5.3 and higher of Ant. The Ant installation directory must contain a lib subdirectory which contains the ant.jar binary. If you enter a directory that does not match the expected structure, the SDK gives you an error. See the NetBeans help topic for more options.

Save All Modified Files Before Running Ant. If selected, saves all unsaved files in the SDK before running Ant. It is recommended to leave this property selected because modifications to files in the SDK are not recognized by Ant unless they are first saved to disk.

Reuse Output Tabs from Finished Processes. If selected, writes Ant output to a single Output window tab, deleting the output from the previous process. If not selected, opens a new tab for each Ant process.

Always Show Output. If selected, the SDK displays the Output window for all Ant processes. If not selected, raises the Output window tab only if the Ant output requires user input or contains a hyperlink. Output that contains hyperlinks usually denotes an error or warning.

Verbosity Level. Sets the amount of compilation output. Set the verbosity lower to suppress informational messages or higher to get more detailed information.

Classpath. Contains binaries and libraries that are added to Ant's classpath. Click Add Directory or Add JAR/ZIP to open the Classpath Editor.

Properties. Configures custom properties to pass to an Ant script each time you call Ant. Click Manage Properties to edit the properties in the property editor. This property is similar to the Ant command-line option, -Dkey=value. The following default properties are available:

${build.compiler.emacs}. Setting this property to true enables Emacs-compatible error messages.

5.4.2 Compiling

To view this property page, right-click on a project and choose Properties. In the Properties window Build category, choose Compiling.

This page enables you to set the following options:

Generate Debugging Info. If checked, the compiler generates line numbers and source files information. This is the -g option in javac. If unchecked, no debugging information is generated (the -g:none option in javac).

Debug Block Level. The block level can be set to: debug, info, warn, error, and fail.

Compile with Optimization. If checked, the compiled application is optimized for execution. This is the -O option in javac. Optimizing can slow down compilation, produce larger class files, and make the program difficult to debug.

Report Uses of Deprecated APIs. If checked, the compiler lists each use or override of a deprecated member or class. This is the -deprecated option in javac. If unchecked, the compiler shows only the names of source files that use or override deprecated members or classes.

Encoding. Overrides default encoding used by preprocessor and compiler. The default value is the default encoding used by your VM.

5.4.3 Adding Libraries and Resources

To view this property page, right-click on a project and choose Properties. In the Properties window Build category, choose Libraries and Resources to add a dependent project, libraries, and other supporting files to the current project.

Add Project. A JAR file produced by another project and the associated source files and Javadoc documentation. Adding this item to a classpath sets up a dependency between the current project and the selected JAR file.

Add Library. A Library is a collection of JAR files or folders with compiled classes, which can optionally have associated source files and Javadoc documentation. If the Package checkbox is checked the library is included in the application's JAR file. If it is not checked, the library is copied into the lib directory.

Add JAR file. A JAR file created by another project.

Add Folder. The root of a package or directory containing files.

When a library or resource is added, it is visible in the Libraries and Resources table, which reflects the order of the libraries and resources in the classpath. To change the order in the classpath, select the listing and click Move Up or Move Down. You can also remove libraries and resources from this page.

Each row in the table has a Package check box. If Package is checked, the library or resource is bundled and added to the project JAR file. If Package is not checked, the library or resource is copied to the lib subdirectory at build time.

5.4.4 Creating JAR and JAD Files (Packaging)

To view this property page, right-click on a project and choose Properties. In the Properties window Build category, choose Creating JAR.

You can set the following options:

JAD File Name. Name of the JAD file created by the project sources. The file name must have a .jad extension.

JAR File Name. Name of the JAR file created by the project sources. The file name must have a .jar extension.

Compress JAR. If checked, the JAR file is compressed.

5.4.5 Obfuscating

To view this property page, right-click on a project and choose Properties. In the Properties window Build category, choose Obfuscating.

Use the Obfuscation properties page to set the level of obfuscation for project files.

Move the Obfuscation slider to set the level. The Level Description window describes the impact each level has.

You can add more obfuscation parameters in the Additional Obfuscation Settings window.

5.4.6 Signing

To view this property page, right-click on a project and choose Properties. In the Properties window Build category, choose Signing. These properties allow you to enable signing and assign key pairs to a CLDC project. See Section 13.1, "Security Domains".

Sign Distribution. Check this box to enable signing for the MIDlet suite. If it is unchecked, this page is disabled.

Keystore. A file that stores one or more key pairs as a keystore (.ks) file. The dropdown menu lists all available keystores. Click the Unlock button to unlock a keystore with the keystore password.

Alias. A name assigned to a key pair within a keystore. The dropdown menu lists the aliases available for the selected keystore. Click the Unlock button to unlock a key pair for use.

The Certificate Details window provides information about the certificate assigned to the key pair.

Click Open Keystores Manager to manage keystores and key pairs. See Section 13.4, "Managing Keystores and Key Pairs" and Section 5.4.8, "Exporting a Key".


Note:

CDC projects cannot be signed with the Signing tool. See Section 5.4.7, "Signing CDC Projects".


5.4.7 Signing CDC Projects

To sign a CDC project use the JDK jarsigner command from the command line. For example:jarsigner.exe -keystore keystore.ks -storepass keystorepwd MyCdcApp.jar dummyCA

5.4.8 Exporting a Key

Follow these steps to export a key into an emulator:

  • Select Tools > Keystores. This opens the Keystores Manager.

    You can use the Keystores Manager to add a keystore to the Keystores list. Click the Add Keystore button. After you create the keystore, click New to create a key pair.

  • In the Keys area, select a key, and click Export. This opens the dialog Export Key into Java ME SDK/Platform/Emulator.

  • Select the target emulator from the Emulator list.

  • Select the Security Domain.

  • Click Export to export your key pair to the selected emulator.

    Your key is added to the bottom of the list in Keys Registered in the Emulator.

The Export window has the following components:

Keystore File. Displays the name of the keystore file to which the key pair belongs. This field cannot be edited.

Key Pair Alias. The name given to the key pair within the keystore. This field cannot be edited.

Certificate Details. Displays the details of the certificate of the key to be exported.

Emulator. The drop-down menu lists all the device emulators available. See Section 13.1, "Security Domains".

Security Domain. Enables you to select a security domain for the key pair. The menu lists all domains supported by the selected emulator platform.

Keys Registered in the Platform. Lists all keys that have been registered in the selected platform. Click to select the key you want to export.

Delete Key. Deletes a selected key from the Keys Registered in the Emulator window.

Export. Exports the selected key to the selected emulator. The export button is enabled if it is possible to export the key. If a specific key is installed it cannot be installed again.

5.5 Running Settings

To view this property page, right-click on a project and choose Properties. In the Properties window, choose Running. The options shown depend on the platform. See Section 5.5.1, "MIDP Project Run Options".

5.5.1 MIDP Project Run Options

To set emulator command line options for a MIDP project, type in the command line switches. See Section 14.3, "Emulator Command Line Options".

Description of project-running.gif follows
Description of the illustration project-running.gif

For CLDC projects, the Regular execution button is enabled by default. The setting for "Specify the Security Domain" applies when the project is run on an emulator. It does not apply for OTA provisioning or an external emulator platform.

If you do not check Specify the Security Domain the project runs with the default that was assigned when the project was created. If you check the box, you can select a domain from the dropdown list. See Section 13.1, "Security Domains" and Section 13.2.2, "Specify the Security Domain for a Project".

5.5.2 CDC Project Run Options

For CDC projects you must enter the name of the entry point Java file in the Main Class field. The Main Class Browse button only shows executable classes in the project's source folders. For a CDC project you see all classes with a static main method, or classes extending the Applet or Xlet classes.

Arguments are passed only to the main class, not to individual files. If an Xlet is executed, all arguments are passed to all the Xlets you specify.

For VM options, see Section 14.3.2, "CDC Options".