Book Image

Instant JRebel

By : Jonathan Lermitage
Book Image

Instant JRebel

By: Jonathan Lermitage

Overview of this book

JRebel is a JVM plugin that lets Java developers update code instantly and see their changes reflected in their application under development without restarting the application server. JRebel is a plugin for anything that is in Java and is also IDE neutral. If you want to update your code instantly without compiling and deploying the code repeatedly, this book is for you.This book will focus on the most important development steps and will also help you save time which is otherwise spent on compilation and deployment of code. You will learn how to use JRebel with the most popular IDEs and Java servers and how to accelerate the development of your current and future Java SE and Java EE projects.This book shows you how to install JRebel, configure your favourite IDE and Java server for JRebel, and start using it on your projects.With this book, you will learn how to get a free license for JRebel and how to integrate JRebel with most Java servers and development environments. To finish, you will see how to work with desktop and web projects and how to utilize JRebel to dramatically accelerate their development.
Table of Contents (7 chapters)

JRebel for a standalone GlassFish server (Should know)


We'll see how to install and activate JRebel on GlassFish standalone server.

How to do it...

The following are the steps that describe how to activate JRebel on GlassFish server:

  1. Download and GlassFish server from https://glassfish.java.net/download.html and unzip it.

  2. Launch GlassFish with the startup script located in its bin folder (bin\asadmin.bat on MS Windows). To start the default domain, run this command: asadmin start-domain domain1.

  3. Enable the JRebel Java Agent for the GlassFish server. To proceed, launch your favorite Internet browser and visit http://localhost:4848/, you will be connected to the administration interface of GlassFish. Navigate to Configurations | server-config | JVM-settings in the left-side panel.

  4. Add the two JVM options: javaagent:C:\packtpub\jrebel\jrebel.jar and -Drebel.log=true.

How it works...

To proceed, you will need the latest version of GlassFish 3 (or GlassFish 4), and a Java 6 (or Java 7) JDK. Once installed and configured, launch GlassFish with its startup script l.

Launch your favorite Internet browser and visit http://localhost:4848/.

Now, add two JVM options as displayed on the following screenshot:

  • -javaagent:C:\packtpub\jrebel\jrebel.jar

  • -Drebel.log=true

    Setting JVM options in GlassFish

You already know the first JVM option, this is the JRebel Java Agent.

The second JVM option asks JRebel to enable its logs. These logs will contain information about your current license validity, and so on. We have to turn on this option because GlassFish won't write JRebel logs to the default output. So, without JRebel logs, you could not know If JRebel is correctly loaded by GlassFish.

When you have added the two JVM options and validated the corresponding form, shut down your GlassFish server with the asadmin stop-domain domain1 command. After that, start your server again and check the C:\Packtpub\jrebel\jrebel.log file. It will contain a lot of information, including the message that indicates your license is active.

Now, please note that you don't need the -Drebel.log=true JVM option anymore; we used it to check JRebel configuration only. You can edit the GlassFish JVM option list and remove it. Re-enable it only if you encounter problems with JRebel.

Congratulations, your server is now configured to run JRebel!