javac#dependency-injectionpreprocessor-directivestaging

How to provide preprocessor directives in Java


CHow can I correctly provide the following functionally from C# in Java?

[C#]

#define PRODUCTION //Change from sandbox to production to switch between both systems.

#if SANDBOX
    using NetSuite.com.netsuite.sandbox.webservices;
#endif

#if PRODUCTION
    using NetSuite.com.netsuite.webservices;
#endif

Solution

  • Java doesn't have a preprocessor - so the simple answer is that you can't.

    This sort of thing is normally handled in Java using Dependency Injection - which is both more powerful and more flexible.

    http://www.vogella.com/articles/DependencyInjection/article.html