It is no secret that Java projects take a long time to build. This long build time is variable depending on how many classes your
project has among other things. Let's say you're a developer that likes to frequently check his or her work. Say a typical
redeployment time for your app is around three (3) minutes and you perform four (4) application restarts an hour. This is a lot of time
you've just spent waiting around and not developing your application.

This is where JRebel by ZeroTurnAround comes into play.

What is JRebel

JRebel is a plugin that supports many popular IDEs and build platforms and it allows you to reload changes to class files, resources,
and frameworks without having to go through the entire build and redeployment process again.

Let's go back to my initial example. As of right now you're spending around ninety-six (96) minutes per day waiting for your
application to be ready. According to the JRebel documenation, by removing
the restart processes and shaving down the redeployment times, you can save yourself around sixty (60) minutes per day.

So how does one get this in their project, or more importantly, a project that makes use of Couchbase Server and the
Couchbase Java SDK?

Including JRebel in Your Project

Although JRebel supports many IDEs, this example will reference IntelliJ IDEA.

Per the JRebel documentation, access the IntelliJ Settings if you're using Windows or Preferences
if you're using Mac. You'll want to choose Plugins and click the Browse Repositories button.
Search for JRebel and install it.

With the plugin installed you'll have to activate your license to JRebel. Once you do this, JRebel should be ready for use! More
can be seen in the official JRebel documentation in terms of setup.

Testing JRebel with Couchbase

When I write queries I tend to write bad queries or queries with bugs. Having to sit through a long deployment process because
of a bad query brings me a lot of sadness. This makes JRebel a useful tool for this particular example situation.

To keep things simple, go ahead and check out the following CouchbaseLabs project called
restful-angularjs-java from GitHub. You'll need Couchbase
installed with an index configured for querying. This can be seen, along with some background on the project, at a previous blog
post that I wrote called Create a Full Stack App using Java and Couchbase Server.

We're going to run this application and then make a change to one of the queries. Start by running the project using the
Run with JRebel 'spring-boot:run' from the Run menu and verify that it works in your web browser
by navigating to http://localhost:8080. We're going to edit the following query:

The above query is found in the getAll function of the src/main/java/couchbase/Database.java file. Go
ahead and alter the query slightly. Maybe add a LIMIT or something else that is simple.

Instead of redeploying the application, choose Build -> Make Project from the menu. Now go back to your web browser
and refresh the page. The page should reflect whatever you changed the query to.

This is very convenient when it comes to developing and testing your application since making the project is much quicker than
running it.

Conclusion

Deploying Java applications take time, but using tools like JRebel saves a lot of it. Using JRebel with your Couchbase Java
application can save you a lot of trouble when it comes to developing your queries, configuring your buckets, and anything else
related to the development of your project.

Author

Posted by Nic Raboy, Developer Advocate, Couchbase

Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.

Leave a reply