Home

News: Dynamic loading using Java Reflection and Properties

  1. If you were wondering how to dynamically load a class based on some configuration or settings file, then ypou might be able to solve your problem using Java Reflection and Properties.

    The Properties file are basically a collection of key-value pairs. It is one of the most commonly used mechanism for storing applications configuration data and settings.

    Reflection is a feature available in Java used by developers for examining and modifying the run-time behavior of applications running in the JVM.

    Click here to read the full article and download complete source code.

    Threaded Messages (4)

  2. Indeed, the good old Class.forName (available since Java 1.0) can be used for dynamically loading and instantiating classes. There are some caveats, however, to be aware of when using it in an environment leverages multiple classloaders.

    More recent methods for implementing interface/implementation loose coupling include dependency injection frameworks and the Java java.util.ServiceLoader API.

  3. Nothing changed[ Go to top ]

    The same article seen here from 2003 with almost the same code. Simple solutions to simple problems didn't change since those old days, so a simple link would have been better than copy/paste :-)

     

  4. Not copy paste.[ Go to top ]

    Hi Wy Marsalis, Thanks for your reply and concern. But, I have never seen the article that you have pasoted in your comment. Java framework and the knowledge is open to every Java programmer and anyone can come up with this solution. And I do not see any resemblence in the two articles.

    Infact I was also planning to write another article in continuation to this with more additional functionalities.

  5. pool specific objects to get better performance