JRebel Tutorial: Using JRebel with InteliJ IDEA

In this document we’ll cover how to setup JRebel for your project while using IntelliJ IDEA as your IDE of choice. We’ll be covering general configuration tips and the two plugins that we have for IntelliJ IDEA users. We concentrate mostly on the version 10.x/11.x versions of IDEA, though most of it should be valid for 9.x users.

Contents:

STEP 1: Installing JRebel IntelliJ IDEA plugin

The plugin is hosted at the central IntelliJ plugin repository. The easiest way to install is to go to File » Settings » Plugins in IntelliJ and use the built-in interface for installing. The plugin name is JRebel Plugin. You can check out the plugin page for more information about the releases of the plugin.

STEP 2: Configure the plugin

Configuring the JRebel plugin is easy – there’s no need to configure it as JRebel itself is bundled with the plugin, so after the plugin is installed – your all set. However, sometimes you may want to use the nightly build version of JRebel – then you just need to specify the path to jrebel.jar. The option is located at Settings » JRebel » JRebel location. You should uncheck the “Use embedded JRebel version” checkbox in order to be able to specify jrebel.jar location.

You should also configure the debugger to ignore synthetic methods. To do that open up debugger properties (File » Settings » Debugger). On the lower left corner of the debugger settings page make the necessary changes. Be sure to tick Skip synthetic methods checkbox. You should also untick the checkbox Synthetic fields in the Show block of File » Settings » IDE settings » Debugger » Data Views

STEP 3: Make a rebel.xml for your application

The rebel.xml configuration file controls how JRebel propagates updates to your application. Specially, it allows you to have a WAR/EAR application deployed as one file to pick up updates made to the project files in the workspace. For this to work you’ll need to have one rebel.xml file per module. This includes both web and EJB modules. The rebel.xml configuration file should end up in the WEB-INF/classes directory in case of a web module and in the jar root in case of an ejb module.

Now JRebel plugin can generate the necessary rebel.xml file for you. Remember though – since it generates this file on a per project basis, you have to be careful if you have more than one module corresponding to that project.  If you do, you should edit the rebel.xml file manually as described in the Installation manual.

To generate the rebel.xml file right click on your project and pick Generate rebel.xml.

Generate rebel.xml

Repeat this for all projects that you’d like to update with JRebel.

The generated rebel.xml will use absolute paths to your project, so you might want to edit it manually and replace the absolute path with a system property as described in the Tips and Tricks section of the Installation manual. If you use Maven you may prefer to use the JRebel Maven plugin that will generate the rebel.xml in accordance with the module pom.xml as described in the Maven Plugin configuration manual.

STEP 4: Launch application with JRebel

This plugin introduces 2 new launch buttons. One for starting the container with JRebel and the other for starting the container in debug mode with JRebel enabled.

STEP 5: Success!

To check that the installation was successful access a page that uses a class, change that class in the IDE, press Save, access the page again and look for the following message in the console:

JRebel: Reloading class …

Now that you’re up and running, it’s time to enjoy coding without the need to redeploy.  If you have any specific questions about this plugin, the Plugin forum is the best place to ask, so that other people get to hear the answer as well.  Otherwise, you can contact us at support@zeroturnaround.com or give us a quick mention on your blog or via twitter (you can even follow us here).

Have a great day!