This article applies to the following:
- 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
If, else, end if block:
<tag>is defined, then the code between
elseis executed; otherwise,
#endifis executed. The
elsesection is not mandatory.
If not, else, end if block:
#ifndef is the opposite of
<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.
- 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:
-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.