Java Program to load an changed class without server restart

849 Views Asked by At

I need a java/j2ee program, that will load an updated class file when the server is still on. In our Web Application testing environment few classes(Java files) are being frequently changed to fix defects and need to load them in JVM fresh. We can not restart the server to impact on going testing .

Can we write a program to load it using class loader?

2

There are 2 best solutions below

0
logger On

No you cannot, you would need to have the container on the server side. Although for your server like tomcat, jboss, websphere etc. you can configure them to hot deploy but the server side would still needs restart once new class file is placed. If you are trying to hot deploy a class file you can try using JRebel it will allow you to hot deploy the class file without actually restarting because it is managed within JRebel container. (also note that JRebel is not free)

0
Abhay Phougat On

There are quite a few solutions/plugins which help you with hot-deployment of java code saving you with complete build and server restart. I had used jRebel earlier available at https://www.jrebel.com/products/jrebel. There are other such solutions/tools that can help you with the hot deployment.