Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java ME (J2ME) Developer Guide
Previous Page Home Next Page

Preparing Eclipse

In this section, you will verify that Eclipse is properly set up for Java ME development.

The following is assumed:

  • You are starting with a new Eclipse installation with default settings.
  • You are familiar with the basic Eclipse workbench mechanisms, such as views and perspectives.

If you're not familiar with the basic workbench mechanisms, please see the Getting Started chapter of the Workbench User Guide.

Java ME SDK installation

In order to use MTJ, you must configure at least one device from a Java ME SDK, performing the following steps:

  1. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Workbench)")"> Goto workbench preferences Window > Preferences... to open the workbench preferences. 

  2. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.mtj.ui.preferences.deviceManagementPreferencePage)")"> Goto the Device Management preference page Java ME > Device Management preference page to display the installed SDKs.


    Device Management preference page

  3. New devices can be added by searching the hard drive for installed Java ME SDKs. To do so, simply click the Import... button.

  4. In the resulting dialog, select the root directory to be searched to find known devices definitions.


    Import Devices wizard

    As you leave the search directory text field or select the Refresh button, MTJ will begin looking for devices in the specified directory and all subdirectories.

    It is not necessary to pick the "perfect" directory in order to have the devices from a SDK imported, as MTJ should be able to locate them if they reside anywhere within the specified directory.

    The devices from the SDKs will be displayed as they are being found, and if you wish to stop the search at any time, select the Cancel button.

    After the search has completed, use the checkboxes to select the device definitions to be imported. Only devices that have been imported into your configuration may be used by project definitions and for launching.

    Finally, click the Finish button to complete the import process.

  5. If you successfully completed adding at least one device from the Java ME SDK, you should see the newly installed SDK in the Installed SDKs combobox and its imported devices in the Devices table as seen below.

    Device Management preference page with the newly instaled SDK devices


Debug Settings

In order to debug your Java ME MIDlet, you must change some of the default Java debug settings, performing the following steps:

  1. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Workbench)")"> Goto workbench preferences Window > Preferences... to open the workbench preferences. 

  2. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.JavaDebugPreferencePage)")"> Opens the Java Debug preference page Java > Debug to open the debugging preferences. 

  3. Ensure that both Suspend execution on uncaught exceptions and Suspend execution on compilation errors near the top of the dialog are NOT checked.

  4. Increase the Debugger timeout near the bottom of the dialog to at least 15000 ms.

  5. The resulting settings should be something similar to this:

    Final debugging settings


  6. To save the preferences, simply click on the OK button

Configuring Preprocessor Support

Due to limitations in the extensibility of the Eclipse Java Compiler (see Bug 116143 for further information), it is necessary for MTJ to hook into the Eclipse platform at a lower level in order to provide preprocessor support. If you would like to take advantage of MTJ's support for preprocessing, a few extra changes need to be made to your Eclipse installation.

The Eclipse configuration file must be altered to reference the MTJ framework hooks bundle.

  1. Locate the file config.ini. This file is located in the <eclipse install>/configuration directory.
  2. Edit the config.ini with your favorite text editor.
  3. Add the property definition bellow to the configuration file.

    osgi.framework.extensions=org.eclipse.mtj.core.hooks
    
    If the property already exists, append ",org.eclipse.mtj.core.hooks" to the end of the current property definition.

    It is very important that the line be added before the end-of-file marker. Failure to properly place the new line before the end-of-file marker could cause your Eclipse workbench to fail to start.
  4. Save the configuration file.
  5. You will need to restart your Eclipse installation.

You will be warned if you have projects that are configured for preprocessing, but the necessary configuration changes have not been made. In this case, a warning will be written to the Eclipse workspace log file with text similar to
"Preprocessor invoked, but hook is not installed. Consult the installation instructions for MTJ."
For more information on viewing the workspace log file see the troubleshooting section of the MTJ documentation.

Configure ProGuard

In order to use ProGuard to produce obfuscated packages, you will need to configure it into MTJ, performing the following steps:/p>

  1. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Workbench)")"> Goto workbench preferences Window > Preferences... to open the workbench preferences. 

  2. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.mtj.ui.preferences.ObfuscationPreferencePage)")"> Goto the Obfuscation preference page Java ME > Packaging > Obfuscation preference page to display the Obfuscation preferences.


    Obfuscation preference page

  3. Configure the ProGuard Root Directory near the top of the dialog.

  4. Configure any other ProGuard-specific settings that you need.

    Important note for Microsoft Windows Users: By default, ProGuard assumes that you are using an operating system that can distinguish between two file names that differ only in their case (i.e. A.java and a.java are two different files. This is clearly not the case in Microsoft Windows. Windows users should be sure to specify the -dontusemixedcaseclassnames option to ProGuard. If you fail to do this, and if you have more than 26 classes in your project, ProGuard's default use of case-sensitive file names will cause classes to overwrite one another. For safety, the -dontusemixedcaseclassnames option is included as one of the default arguments to ProGuard. UNIX users with projects with many classes may be able to achieve a small reduction in the final size of their JAR file by removing this option.

  5. To save the preferences, simply click on the OK button

Configure Over The Air options

In order to debug your MIDlet in Over The Air (OTA) mode, you may want to adjust the OTA Preferences, performing the following steps:

  1. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.Workbench)")"> Goto workbench preferences Window > Preferences... to open the workbench preferences. 

  2. href="eclipse_java_me_javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.mtj.ui.preferences.J2MEOTAPreferencePage)")"> Goto the Over the Air preference page Java ME > Over the Air preference page to display the Over the Air preferences.


    Over the Air preference page

  3. Configure Over The Air options
  4. To save the preferences, simply click on the OK button



 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire