1

I just set up JRebel to use with my Spring web app in IntelliJ, and was very surprised to learn that I have to manually rebuild the project/recompile every time I want my changes to be reflected. Doesn't this defeat the whole purpose of JRebel? Is there something I'm missing here? With Eclipse it was nearly instant, make changes anywhere, save, instantly reflected in running app. With IntelliJ the process seems very clunky. Am I missing something here?

secondbreakfast
  • 4,194
  • 5
  • 47
  • 101

1 Answers1

4

Running with JRebel in IntelliJ involves starting your application using Run > Run with JRebel and when you change your application code you have to build the project in order for IntelliJ to compile classes and update your application.

You can do this by running SHIFT + F9 or Build > Build Project

From the JRebel docs:

JRebel relies upon your IDE to do the compiling. JRebel reloads your compiled .class files and not your .java files. When you change code, JRebel pushes the changed classes and resources to the server without redeploying.

Regardless of what IDE you use, JRebel still needs the IDE to compile the classes before it can update the running application. IntelliJ is no different to Eclipse in this regard. Perhaps Eclipse was just auto building the project without you being aware of it. You can also instruct IntelliJ to auto build from Preferences > Build, Execution, Deployment > Compiler > Build project automatically.

Here's a screenshot showing that configuration setting:

enter image description here

glytching
  • 44,936
  • 9
  • 114
  • 120
  • I see. It does seem a tad bit slower though, but maybe thats just me thinking it is since I have to do it manually. I'll try out that auto setting, thank you – secondbreakfast Sep 20 '17 at 19:24
  • 1
    Also, Eclipse incremental compiler might rebuild the whole project time to time. Then the timestamp of the *.class files would be updated even if the source didn't really change. Since JRebel relies only on the timestamp of the files by default (for performance reasons) it might start reloading too many classes. If this happens too often when you use Eclipse, you might want to set the -Drebel.check_class_hash=true VM argument to enable hash based approach for change detection. – Anton Arhipov Sep 21 '17 at 14:02
  • 1
    In IntelliJ IDEA the automatic compilation has a delay: first there's a a delay for auto-save which is 2000 AFAIR, and after that there's a 300 millisecond delay for compiler to start. Those timeouts are configurable in the internal registry. So it might take some time to get used to :) – Anton Arhipov Sep 21 '17 at 14:03
  • @AntonArhipov: thanks for the additional information – glytching Sep 23 '17 at 14:35
  • The hash checking is enabled by default on the JRebel Agent(non-legacy) – Murka Sep 26 '17 at 14:14