If you are Java Developer looking to get an application up and running quickly, there are a few different routes you can take. If you are using a tool like Maven, you can start with an archetype, which is a bare bones sample application based on some criteria. Another popular option is to use a code generator. Typically you will look for a tool to generate as much boilerplate code as possible.

There are two main options, based on your preference of Java EE or Spring framework. If you prefer Spring, there is a tool called Spring Roo, it generates a lot of code for you and uses aspect-oriented programming to hide most of the unnecessary details. If however, you prefer Java EE, then JBoss Forge project is for you. Forge does an excellent job of generating clean, easy to read boilerplate, no aspect-oriented programming necessary. Forge also supports a robust plugin system that allows you to generate more than just Java EE apps, you can even use it for Spring too!

Maven archetypes are okay, but not nearly as customizable as using a code generator. Go ahead and install JRebel and Forge, then follow along! With tools like Roo and Forge, you can open a prompt and generate a new “forge” project like this:

project-new --named ztdemoproject

After running this command, we’ll have an empty maven project structure with a pom, it’s a web application that will be packaged as a WAR file. One really cool feature of the JBoss Forge command line is tab completion; you can list and set all kinds of useful details to your forge commands, just like a real OS CLI.

Now, let’s do something useful with our application, after all, just starting up WildFly an empty app is only marginally useful. Let’s add a persistence layer and entities to our app, Forge is pretty good with defaults, so we’ll use the container default data-source from WildFly. Forge’s command line changes contexts and now should show a prompt similar to this:

[ztdemoproject]$

From here we can type a command to forge to generate an entity and setup our persistence layer and scaffold a basic JSF frontend:

We’ve now got a basic project setup with forge, so enable JRebel according to the normal instructions here: http://zeroturnaround.com/software/jrebel/learn/
The important bits are making sure the java agent is added to the jvm (the server configuration) and the rebel.xml is in the application (the application configuration). When we start our application, we can verify JRebel is running because we’ll see the JRebel banner in the server output:

So it looks like forge did a good job of bootstrapping an application with a persistence layer, JSF for the frontend, and gave us a reasonably nice looking application. We see there is a Person button, and Person has a name field. You also had the option of scaffolding REST endpoints as well.

We haven’t written a single line of code yet, and we’ve got a functional Java EE app running on WildFly. Since we have JRebel to cut out those nasty redeploys, we can keep using Forge to generate more pieces in our app and just need to call the scaffold-generate command, no rebuild or redeploy required to see the changes. Let’s add a new field to our entity, and then rescaffold:

Then we can just hit refresh, and we’ll see that the “Create a Person” screen now has our new field. In the console or server output, we can see JRebel not only reloaded some classes, but also reconfigured the SessionFactory, so our persistence layer can generate whatever it needs to so we can interact with our new model.

JRebel: Reconfiguring SessionFactory due to changes in [file:/path/to/Person.class]

The combination of JRebel and JBoss Forge may be the best combination possible to speed up your development. Of course, you will need to modify the generated code and resources to fit your needs, but don’t worry, JRebel will pick that up as well. Why not try JRebel today, get a 14 day free trial, and get amped-up with JRebel and Forge.

Adam Koblentz is the Product Marketing Manager for JRebel. He has worked for several years in the financial industry writing backend frameworks and software for highly available and concurrent systems. Now he spends his days bringing awesome and liberating software to developers around the world. Adam gets satisfaction from increasing the quality of life of the every day developer.