"ifdef" in java
2 posts in topic
Flat View  Flat View

Posted By:   mark_webb
Posted On:   Monday, June 25, 2001 09:30 AM

Is there a way to implement an "ifdef" in java. We have a program that will be using MD5 or PKI in a program for security. Is there a way to either build the "PKI" program or the "MD5" program using some sort of functionality like what is in C/C++? I would rather not use a config file to specify the difference, so what are my options here ??


Re: "ifdef" in java

Posted By:   John_Mitchell  
Posted On:   Tuesday, June 26, 2001 01:48 PM

RTF: How can I implement conditional compilation in Java?

In terms of your underlying design question, I suggest using the Abstract Factory or the Factory Method design patterns (see the Patterns FAQ for more information).

Re: "ifdef" in java

Posted By:   AlessandroA_Garbagnati  
Posted On:   Monday, June 25, 2001 12:19 PM


I had a similar problem in the past. In my case I was using a specific implementation of an interface, based on a series of factor. The simplest solution (I had no time to think of something better) was to insert the right class and have my code trying to create a new instance of the class using Class.forName().newINstance(). If that was giving me a ClassNotFoundException, then I was initializing the other.

I know, this is not the best solution but I hope it could give you some hints.

About | Sitemap | Contact