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
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.
Examples of some preprocessor directives are: #include, #define, #ifndef etc. Remember that the # symbol only provides a path to the preprocessor, and a command such as include is processed by the preprocessor program. For example, #include will include extra code in your program.
Preprocessor directives are lines included in a program that begin with the character #, which make them different from a typical source code text. They are invoked by the compiler to process some programs before compilation.
Java doesn't have a general purpose define preprocessor directive. private static final int PROTEINS = 100; Such declarations would be inlined by the compilers (if the value is a compile-time constant).
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
Java doesn't have a preprocessor, yet that doesn't mean that you can't run Java code through cpp
- though it would not be supported by any tools, AFAIK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With