Using JRebel with IntelliJ IDEA on OS X
Join the DZone community and get the full member experience.Join For Free
Yesterday afternoon, I figured out how to use JRebel with IntelliJ IDEA. I wrote up some AppFuse documentation for it at Using JRebel with IntelliJ IDEA and figured I'd repost it here for those developers using IDEA 9 and Maven.
- Download and install IntelliJ IDEA 9 Ultimate Edition (in /Applications on OS X).
- Download and install JRebel.
- java -jar jrebel-setup.jar
- Install the JRebel Plugin for IDEA. Shortcut: File > Settings > Search for plugins and find JRebel.
OS X, Modify /etc/launchd.conf and add the following so M2_HOME is
available to GUI apps. You'll need to reboot after making this change.
setenv M2_HOME /opt/tools/maven2
More info on this setting is available on Stack Overflow.
- Modify your project's pom.xml to include the JRebel Maven plugin (for generating the configuration of which directories and files to watch for changes).
- If you're using the Maven Jetty plugin, change your pom.xml so Jetty doesn't reload the app when classes are compiled. Specifically, change scanIntervalSeconds to 0. If you're not using this plugin, you should definitely check it out for Java webapp development.
- Use the JRebel icons to start jetty:run in your IDE.
- Command Line Integration: Set a JREBEL_HOME
environment variable that points to your JRebel install
(/Applications/ZeroTurnaround/JRebel on OS X) and set your MAVEN_OPTS
to use JRebel's settings. For example:
export JAVA_OPTS="-Xmx512M -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.awt.headless=true"
export MAVEN_OPTS="$JAVA_OPTS -noverify -javaagent:$JREBEL_HOME/jrebel.jar"
After making these changes, you should able to compile classes in IDEA and refresh your browser. Log messages like the following should show up in your console.
JRebel: Reloading class 'org.appfuse.webapp.action.UserAction'.
To simplify things further, you can map Command+S to compile (instead of Shift+F9). Just look for Keymaps in Settings, rename the default one and search for Compile to remap.
I'm assuming the steps to make things work on Windows and Linux are similar. Please let me know if you have any issues with these instructions.
Opinions expressed by DZone contributors are their own.