Conditional Compilation (or something like this!)

Hi all.

In my application I would need to conditionally import a jar, depending on a configuration switch.

I'm attaching here some sample code (written in "c++ conditional compilation mode") to explain better the situation:

#ifdef (VERSION_5)

path.to.mypackage.MyClass mc =new path.to.mypackage.MyClass();

mc.doSomething();

#endif

What I need is not to be forced to include the package "path.to.mypackage" at compile-time if the version is not VERSION_5.

Any help will be very appreciated!!

[580 byte] By [robicha] at [2007-10-2 14:05:18]
# 1
Java does not have a preprocessor. Opinion is divided on the need - see this search list: http://www.google.com/search?q=java+conditional+compilation
ChuckBinga at 2007-7-13 12:14:39 > top of Java-index,Developer Tools,Java Compiler...
# 2
I chose this way: provided that there's only one class in which I have to use the path.to.mypackageMyClass class, I load this class (runtime if conditioned) through reflection.So, the compiler doesn't require to see that package, that eventually gets loaded runtime.
robicha at 2007-7-13 12:14:39 > top of Java-index,Developer Tools,Java Compiler...