title: Java equivalent of #ifdef that allows non-compilable code
body: <p>Is it possible in Java to do a sort of #ifdef thing, like in C/C++?</p>
  
  <p>Example:</p>
  
  <pre><code>class Test
  {
      public static final boolean ANDROID = false;
  
      public Test()
      {
          if (ANDROID)
          {
              // do stuff that won't compile if not on android
          }
          else
          {
              // do stuff that should be only done on desktop
          }
      }
  }
  </code></pre>
  
  <p>Note that even if <code>ANDROID</code> is <code>false</code>, as in the example, it will still try to compile the code inside of the <code>if</code>, even though it won't (and shouldn't) compile.</p>
  
  <p>I'm looking for a way to do conditional compilation -- the compiler shouldn't even <em>look</em> at the <code>if</code> if <code>ANDROID</code> is <code>false</code>.</p>
  
  <p>The context of my question is that I have a Processing application in Eclipse. I'm using both normal Processing and Processing for Android in two separate projects, but I want to be able to move the source code of the projects between one another without having compiler errors. For example, I want to be able to have source code files that I can move from the Android project to the desktop project and only have to change  a couple of things -- for example, changing <code>ANDROID = true</code> to <code>ANDROID = false</code>.</p>
  
  <p>I really need it to be conditional compilation because when I copy the source code from the Android project to the desktop project, the desktop libraries obviously won't include Android libraries, and then the source code won't even compile.</p>
  
  <p>EDIT: So now that I know that there is no preprocessor in Java, my question is: is there any other way to have this functionality in my projects (being able to copy source code from one to the other with only very minor changes) without having to manually [un]comment specific pieces of code and having to remember where those are?</p>
  
  <p>EDIT 2: This is not a duplicate of the other question because my question includes code that may have compiler errors in it, whereas the question that this was closed as a duplicate of does not. (That other question concerns only code that would compile fine even without <code>#ifdef</code>s.) To explain, the most highly rated (and accepted) answer for the other question talks about code that is <em>compiled</em>, but is simply not <em>emitted</em> in the bytecode. However, my question concerns code that would not even compile originally.</p>