I modified one class of my application, but I don't want to rebuild the whole now and redeploy the whole application.
I just want to create a new jar which only contains this modified class and only deploy this jar.
So when the application restarts, it will load the new class instead of old one.
There are a few ways of doing this, but all are more complicated than redeploying the full app. Why don't you want to rebuild and redeploy the whole app?
Completely unreliable: you should never rely on the new class being picked up first--you do not control the classloader, the classloader might change, etc. Having multiple versions of the same class on the classpath is a recipe for tears.
Ulf Dittmer wrote:There are a few ways of doing this, but all are more complicated than redeploying the full app. Why don't you want to rebuild and redeploy the whole app?
Please let me know these ways of doing this.
Thanks
Ok.
Here is the scenario.
The application is in production. need to modify one class to fix a simple bug.
Dropping a simple jar in the application without touching the whole application is a simple solution for now.
Next release can rebuild the whole application and conduct full test in QA and redeploy it.
I know there was an app. They put a patch jar in a folder of the app.The loader loaded the new class instead of old one when restart the app. Very useful way.
But I did not ask how.
If the use of the class is very localized (and described via an interface), then you can encapsulate its usage via a classloader of your own. If you want to redeploy the class your code can throw away the classloader, and then create a new one that loads the class from the new jar file. It's not trivial, but not particularly hard either if you understand classloaders.
Or you can make it much easier on yourself and use OSGi; this is one of its primary use cases.
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me: