Before trying to use JRebel, let's have a look at the existing features offered by modern IDEs such as NetBeans. They are already able to accelerate your developments. We will see later why JRebel is a better choice.
Also, many developers associate JRebel with Java EE applications only, but keep in mind it works with any Java SE application too, including GUI software!
Modern IDEs offer some ways to accelerate your developments and deployments. We will show one of them, called Deploy on Save on NetBeans using the following steps:
Understand what a class loader is. Download and install the latest version of Oracle JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html (on Ubuntu, you may use
the sudo apt-get install openjdk-7-jdk
command to install JDK7) and NetBeans IDE from https://netbeans.org/downloads/. Please choose the Java EE or All bundle of NetBeans.Download and install the latest binary version of Apache Tomcat server from http://tomcat.apache.org/download-70.cgi. You should use the ZIP version. It is easier to register in NetBeans than the Windows Service Installer version.
Register the Tomcat server in NetBeans by launching NetBeans and going to the Services tab. Right-click on the Servers node, then click on the Add Server... register, then choose Apache Tomcat from the server list to register the Tomcat server.
Create a simple Java web project. You can do it by navigating to File | New Project | Java Web | Web Application. Remember to choose Tomcat as the server. It will create a simple web application with a HelloWorld JSP file. Now, create a simple servlet by navigating to File | New File | Web | Servlet. See the differences when Compile on Save is enabled and disabled. You can activate this feature present in the Projects Properties panel by checking the Deploy on Save checkbox.
A web application is a good example to explain the principle of the Deploy on Save feature of NetBeans.
You probably already know that you can modify and save a JSP file; the server will automatically reload it without restarting or redeploying anything. Meanwhile, servlets are Java classes and won't be reloaded so easily. Without the help from an IDE, you would normally need to rebuild your application and redeploy it.
The Deploy on Save feature is designed to redeploy your servlets automatically. You only have to save the edited file and you'll see the changes immediately.
So, is there anything else to improve the development process?
Unfortunately, the Deploy on Save system is limited it consumes time and can't update the entire web applications or configuration files. This is exactly why JRebel is useful. JRebel is comparable to the best Deploy on Save systems, but it also offers many advanced capabilities. It offers two types of improvements:
Changes to Class structure: This targets Java SE applications (such as desktop applications) and Java EE applications.
JRebel is able to apply changes to many Java elements. The following are the details:
It applies changes to method bodies
It adds/removes methods
It adds/removes constructors
It adds/removes fields
It adds/removes annotations
It adds/removes classes
It applies changes to static field values
It adds/removes enumeration values
It applies changes to interfaces
Instant Builds: It targets Java EE applications only. JRebel is able to apply changes to Java EE elements. The following are the details:
It skips builds for WAR directories
It skips builds for WAR/EAR class updates
It skips builds for WAR/EAR resource updates
It maps multiple source dirs to one WAR/EAR target dir
It maps classes and resources with include/exclude patterns
It maps multiple source dirs with Ant-style patterns
It uses system properties to make mapping machine-independent
JRebel is entirely transparent; simply save the modifications to observe changes in the live application. It works with any kind of Java application.