We are using JRebel at work now for a couple of weeks, and this product is really a timesaver for every Java developer. No need to redeploy/restart your application server: just code and push refresh in the browser.
But, we sometimes had the issue the whole project was getting reloaded and we only changed 1 line of code in 1 class file. After a bit of research, we found out Eclipse just cleans the whole bin folder. Every class file was recompiled.
The reason why is still unknown. I couldn't figure this out. Anyways, it was really frustrating as the only solution to stop the reloading process, was to restart the application server. And if you have to restart the application server, why would you use JRebel?
The first thing I tried is stopping the "Automatic build" option in Eclipse. Disabling build automatically option does not break JRebel. JRebel depends on the results of the compilation, so if you disable the automatic build you will have to just compile the changed classes yourself, that's it.
But I didn't like that option either, so we found an option in JRebel which is actually a VM argument: -Drebel.check_class_hash=true which will check the checksum before reloading the classes. It may slow down the reloading time from a few milliseconds to some milliseconds extra. But it is still better than the situation when all the project classes have to be reloaded.
To summarize, this is my JRebel configuration in $JBOSS_HOME/bin/run.conf:
# JRebel JAVA_OPTS="$JAVA_OPTS -javaagent:$JREBEL_HOME/jrebel.jar -Drebel.log=false -Drebel.check_class_hash=true" JAVA_OPTS="$JAVA_OPTS -D##PRODUCT_NAME##.root=/Users/jochen/Documents/workspace/##PRODUCT_NAME##"
Feedback from JRebel:
I am glad you were able to solve it this way, but while it works, there are two problems with it:
1. There is some performance overhead from checking the hashes.
2. You are curing the symptom, not the cause - something is still re-building your workspace.
But as long as it performs quickly enough for you, then all is well.
I faced the same problem when I started using JRebel and I resolved as follow.
First of all, the cause of the rebuild is this. Each time you launch an application with JRebel nature, the file(s) jrebel.xml is updated in the appropriate project(s) directory. Eclipse then detects a change in the project(s) and starts a rebuild.
To avoid the undesired rebuild, it is needed to change the following setting in Eclipse (Luna version, might be the same for other versions):
Window -> Preferences -> Run/Debug -> Launching -> General Options -> uncheck "Build (if required) before launching".