# 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. To install an SDK and configure a device, go to Java ME > Device Management.

For more information about installing and configuring devices, see Device Management in the on-line help.

## 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. Select the Window > Preferences... to open the workbench preferences.

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

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:

1. Select the Window > Preferences... to open the workbench preferences.

2. Select the Java ME preference page to display the Java ME preferences.

3. Configure the ProGuard Root Directory.

   Note: For the ProGuard Root Directory specified, the package "proguard.jar" will be searched on "lib" subdirectory. If a directory "../proguard" was selected then the file "../proguard/lib/proguard.jar" must exist.

4. Select the Java ME > Packaging > Obfuscation preference page to display the Obfuscation preferences.

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

6. 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. Select the Window > Preferences... to open the workbench preferences.

2. Select the Java ME > Over the Air preference page to display the Over the Air preferences.

3. Configure Over The Air options

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