BlackBerry® Java® Development Environment (BlackBerry JDE)
BlackBerry® Java Plug-in for Eclipse®
RIM Application Program Compiler (RAPC) supports a few basic preprocessor directives. The directives can be used to take advantage of features available in later BlackBerry smartphones and builds without fragmenting into multiple code lines, or to make it easy to remove debug output for final versions.
The following directives are supported:
Enable the preprocessor //#preprocess
If, else, end if block: //#ifdef <tag> … //#else … //#endif
If <tag> is defined, then the code between #ifdef and else is executed; otherwise, #else to #endif is executed. The else section is not mandatory.
If not, else, end if block: //#ifndef <tag> … //#else … //#endif
#ifndef is the opposite of #ifdef. If <tag> is not defined, the code is executed.
When using the BlackBerry Java Plug-in for Eclipse you must first enable preprocessing using the steps outlined here. After this is done you can set preprocessor defines in the Build tab of the BlackBerry_App_Descriptor.xml file as shown in the following image:
If the BlackBerry_App_Descriptor.xml file is not present, update the BlackBerry Java Plug-in for Eclipse to the latest available version. If you have not configured Eclipse™ to use the BlackBerry Java Plug-in for Eclipse update site, this can be accomplished by following the steps found here.
To use the preprocessor in the BlackBerry JDE, you must manually add it to the Java development project (JDP) file. To do this, complete the following steps:
Open the JDP file with an editor.
Go to the line that starts with Options.
At the end of the line, add -define <tag1>;<tag2>;…;<tagN> as in the following example:
The -define statement is simply an argument passed to the RAPC. Therefore, you can use it with your own command line build scripts. This functionality has been present since RAPC version 4.0. >f you use the preprocessor, make sure at least one definition is defined, typically PREPROCESSOR, or it will not engage.