Visual J++ provides two new mechanisms for conditionally compiling code in Java: conditional directives and conditional methods. The table below describes all the conditional directives available. For an overview, see Conditional Directives. For an overview describing the syntax and use of conditional methods, see Conditional Methods.
Note The conditional directive and conditional method mechanisms provided with Visual J++ are extensions to the Java language, provided by Microsoft. Thus, source code containing these mechanisms will not compile properly with other Java development tools.
Conditional Directive | Description |
#if | Conditionally includes or excludes source code, depending on the resulting value of its expression or identifier. |
#elif | Optional use with the #if directive. If the previous #if test fails, #elif includes or excludes source code, depending on the resulting value of its own expression or identifier. |
#else | Optional use with the #if directive. If the previous #if test fails, source code following the #else directive will be included. |
#endif | Required use with the #if directive. The #endif directive closes a conditional block of code. |
#define | Defines an identifier used in preprocessing. |
#undef | Undefines an identifier used in preprocessing. |
#error | Generates a developer-defined error message at compile-time. |
#warning | Generates a developer-defined warning message at compile-time. |