This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I am developing a java application which will have two modules. The main module will remain constant but the plugin module changes over time. Everytime the plugin module changes, its reflected in the version. The main module connects to a server and checks for changes using current and server version and downloads the latest version of the plugin in case its not latest before it actually executes it. Each of the modules are supposed to be as jar files. I run the main module using java -jar mainmodule.jar command. How do i set the classpath to the recently downloaded plugin module which is again a jar file? Any help on this will be greatly appreciated.
You create a new ClassLoader to load the jar. You can use the standard URLClassLoader class. When you need to reload the plugin classes, you discard the URLClassLoader and make a new one with a new class path.
Hey thanks for the reply. I looked thru the JDK api and couldnt figure out much as I havent worked on this class loader apis and stuff. Can you point me to some sample java code where i can find a skeleton of the way to do what i am trying to do? if you could provide any such help, it'll be of great help.
author and iconoclast
where FooImpl is a class in the jar that implements some interface Foo, and Foo is loaded as part of the main application.
To reload the jar, get rid of the object in "foo", just repeat these same three lines -- but make sure you get rid of the old "foo" and any other objects that came from the first ClassLoader or some weird and confusing stuff can happen!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com