Latest news

JavaRebel gets Guice, Struts2, Tapestry 4 and Freemarker support

We are proud to announce specialized support for four new frameworks....

JavaRebel 1.2.1 and Spring Plugin 1.0-M2 Released

We are very proud to present not one, but two simultaneous releases....

JavaRebel used to develop LinkedIn

LinkedIn, Corp. has purchased JavaRebel licenses for all its Java engineers to use in the well-known social networking website dev...

Installation

Using JavaRebel

JavaRebel is a developer tool that will reload changes to compiled Java classes on-the-fly saving the time that it takes to redeploy an application or perform a container restart. It is a generic solution that works for Java EE and Java standalone applications.

JavaRebel installs as a JVM plugin (-javaagent) and works by monitoring the timestamp of class files. When it is updated (e.g. when a developer saves a class from the IDE) JavaRebel will reload the changes to class code and structure while preserving all existing class instances. The loading is lazy and will happen upon usage of the class (method call on an instance, static call on the class, field lookup etc).

The following classes will be reloaded when they are changed and compiled:

  1. All “.class” classes inside the usual classpath (WEB-INF/classes, etc). Using this with exploded deployment will provide the best JavaRebel experience.
  2. All “.class” files in directories specified by -Drebel.dirs (comma-separated list) JVM command line property. With this you can deploy in unexploded development mode (EAR or WAR) and still reload classes instantly. For example -Drebel.dirs=/path/to/eclipse/project-one/bin,/path/to/eclipse/project-two/bin. However new classes (or renamed old classes) will not be loaded before they also appear in the classpath (e.g. after the build in JAR files).

Example: Java EE exploded development

You are developing a Java EE application. You are using exploded development and have deployed the root of your project to the container. The container is loading your classes from WEB-INF/classes. You have installed JavaRebel to the container.

To take advantage of this situation with JavaRebel the developer has to start compiling the class files straight to WEB-INF/classes and instead of redeploying the application JavaRebel will reload code changes.

Example: Java EE unexploded development (WAR or EAR)

You are developing a Java EE application. You are using unexploded development and have deployed a WAR archive to the container. You would like to change Java source files and see the changes propagate without redeploy. You are compiling your classes to c:\projects\app\build\classes.

To take advantage of this situation with JavaRebel the developer has to start the container with JavaRebel and also specify the location of the classes, thus -Drebel.dirs=c:\projects\app\build\classes. JavaRebel will now reload new classes that are compiled to c:\projects\app\build\classes.

Example: Java SE development

You are developing a Java SE Swing application. You are compiling and starting it from an IDE with all the compiled classes being in system classpath. In this case adding the JavaRebel installation command line to the started application will immediately enable class reloading.

More examples:

Installation

Java 5 or later

Add the following to JVM command line (note that it is important that the JAR would be named “javarebel.jar”)

-noverify -javaagent:/path/to/javarebel.jar

Windows examples

  • java -noverify -javaagent:C:\libraries\javarebel.jar -Drebel.dirs=c:\workspace\project\classes com.domain.Application
  • java -noverify -javaagent:C:\libraries\javarebel.jar -Drebel.dirs=c:\workspace\project\classes -jar application.jar

Linux examples

  • java -noverify -javaagent:/home/john/libs/javarebel.jar -Drebel.dirs=/home/john/workspace/project/classes com.domain.Application
  • java -noverify -javaagent:/home/john/libs/javarebel.jar -Drebel.dirs=/home/john/workspace/project/classes -jar application.jar

Java 1.4

The installation for Java 1.4 has two parts:

Generating the bootstrap jar

Running java -jar /path/to/javarebel.jar will generate a javarebel-bootstrap.jar. The file is generated
to the folder where javarebel.jar resides.

IMPORTANT! javarebel-bootstrap.jar is JVM and JavaRebel version specific! If you upgrade your JVM (even a minor version) or upgrade JavaRebel you have to regenerate javarebel-bootstrap.jar.

IMPORTANT! Make sure that the JVM version used to generate javarebel-bootstrap.jar is the same your application will run with!

Example

  • java -jar C:\libraries\javarebel.jar - will generate a javarebel-bootstrap.jar into the folder C:\libraries\
  • java -jar /home/john/lib - will generate a javarebel-bootstrap.jar into the folder /home/john/lib

NOTE The easiest way to ensure JVM and JavaRebel version consistency is to add the javarebel-bootstrap.jar generation to the startup script of your application server. This means that on every startup the javarebel-bootstrap.jar is generated with the JVM that is used to start the server. This is an inexpensive invocation and will not be noticeable.

Adding commandline options to the JVM

JavaRebel requires the javarebel-bootstrap.jar and javarebel.jar to be prepended to the Java bootclasspath as well as the -noverify JVM flag:

-noverify -Xbootclasspath/p:/path/to/javarebel-bootstrap.jar:/path/to/javarebel.jar

Windows examples

  • java -noverify -Xbootclasspath/p:C:\libraries\javarebel-bootstrap.jar;C:\libraries\javarebel.jar -Drebel.dirs=c:\workspace\project\classes com.domain.Application
  • java -noverify -Xbootclasspath/p:C:\libraries\javarebel-bootstrap.jar;C:\libraries\javarebel.jar -jar -Drebel.dirs=c:\workspace\project\classes application.jar

Linux examples

  • java -noverify -Xbootclasspath/p:/home/john/libs/javarebel-bootstrap.jar:/home/john/libs/javarebel.jar -Drebel.dirs=/home/john/workspace/project/classes com.domain.Application
  • java -noverify -Xbootclasspath/p:/home/john/libs/javarebel-bootstrap.jar:/home/john/libs/javarebel.jar -Drebel.dirs=/home/john/workspace/project/classes -jar application.jar

Successful installation check

On successful installation you should see the following message in standard output.

##########################################################

 ZeroTurnaround JavaRebel x.y.z
 ...
##########################################################

See Features for supported JVM and server versions.

IDE configuration

If you are using IntelliJ IDEA you should install this plugin to enable debugging with JavaRebel. You should also configure your IDE for better debugging experience.

Instructions per container

Further you can find specific instructions for different operating systems, application servers and so on. To keep the instructions concise we don’t include the -Drebel.dirs option in the following installation strings.

Choose platform

Standalone Applications

Just run as usual adding the integration string:

java -noverify -javaagent:javarebel.jar MAIN_CLASS ARGS

While developing IntelliJ IDEA or Eclipse plugins start the respected testing IDE instance
with the integration string.