There are several solutions:
Use a preprocessor - I think that it will work with the standard CPP. There were some Java specific proprocessors as jappo and java+ that you can try
Replace the #if 0 with a true if:
if(false) {
code
}
The condition can be refined by querying the system properties:
if(System.getProperty("NO_COMPILE").equals("true")) {
code
}
This has the advantage that it can be easily set either from ANT or from Eclipse.
EDIT: Please remark that with if the code will actually be compiled and present in the .class files. Moreover, although querying system properties is more elegant, is done at runtime not at compile time hence is not quite inline with original requirement. The if(false) is on a 2nd tought better.
EDIT2: an even better solution I have just found: http://prebop.sourceforge.net/