RSS feed
All(28) Eclipse(4) Java(5) JDBC(5) JSP(3) Maven(7) Personal (1) Spring(3) Tomcat(5)
<< Comparison of 2 Java Excel APIs on Large Workbooks/Worksheets | Home | Sample or Example Tomcat MySQL DBCP (Database Connection Pool) Configuration Settings >>

JavaRebel-Compiling and Reloading Java Code on the fly. Is much easier in Unexploded Format

JavaRebel is a tool that allows you to reload classes on the fly without the recompile and redeploy turnaround so common in Java Web Application Development.

There are two ways to develop with JavaRebel now (and maybe more coming it looks like).

Exploded - Point CATALINA_HOME/webapps/webapp directly into your IDEs src directory and use some symlinks to the WEB-INF classes and lib directories.

See my post on exploded development:

Exploded Java Rebel Development

Unexploded- Deploy WAR into tomcat and add some options for rebel.dirs to point into your IDEs target/classes directories (where your ide is background compiling your classes).

Initially I had tried to develop with JavaRebel in exploded format and dealing with symbolic links and maven on a windows box proved troublesome. I think that unexploded is much easier and I would recommend it. 

Unexploded format allows changes to in dependent projects as well. It has a list of directories set up in a JVM option that it looks for new classes. So you can have multiple projects you can add to that list.


http://www.zeroturnaround.com/news/zero-turnaround-in-unexploded-development/
Rebel and WTP http://www.zeroturnaround.com/articles/javarebel-and-wtp-configuration/


In the example below I have added essentially the target class directory from the projects I want to pick up. Its just a comma delimited list of the projects. You could have more or less. For now I just have 3.

This options uses the same maven pom file that I normally use without javarebel, just add some options in the tomcat monitor.

To install all that had to be done was to

Copy javarebel.jar to C:\opt\tomcat\bin

Copy your javarebel.lic file to same location

 Add in tomcat monitor on java tab under java options

-Dcatalina.home=C:\opt\tomcat

-Dcatalina.base=C:\opt\tomcat

-Djava.endorsed.dirs=C:\opt\tomcat\common\endorsed

-Djava.io.tmpdir=C:\opt\tomcat\temp

-Xverify:none -noverify -javaagent:C:\opt\tomcat\bin\javarebel.jar -Drebel.dirs=C:\java\airweb\target\classes,C:\java\aircore\target\classes,C:\java\stdcore\target\classes -Drebel.log=true -Dlog4j.configuration=file:C:\opt\tomcat\conf\log4j.properties

Restart Tomcat of course then go and in and change some action classes in your ide (e.g. eclipse) and make changes in your dependent projects code and hit refresh in your browser and you will see the changes immediately.

Frankly this is amazing to me. I have been learning Groovy, partly for this type of development process. At the beginning of my career I had developed in a proprietary Server Side Javascript, and PHP and basically this makes Java Development easier. It removes the recompile, redeploy to container step that every java developer suffers through. Just edit the code in your IDE hit save and refresh the browser. Prior to this you could make changes to your jsps that would get picked up by the container but not to java classes like this. I have been reading up on Groovy since it allows this type of development. Now I can do this with my old struts application and dependent projects.

One issue I can see that with this one might be tempted to write less junit tests. But this makes life so much easier.  When I have coworkers who have developed in PHP saying that PHP development is faster than java development and we can use this it is really great for Java Development.


Tags :



Add a comment Send a TrackBack