Monday, September 21, 2009

Eclipse and the “must-have” plug-ins for today’s Java development

As most Java developers know, Eclipse is the most popular IDE for Java & JavaEE development. I started using Eclipse Galileo (3.5) lately and thought that I will list down some of the most useful plug-ins used by me & most of my friends. The list is fairly obvious but still … posted here for reference.
Eclipse Base: I use Eclipse Galileo Java EE which comes with most goodies necessary for Java, EE, XML, Mylyn etc.
Listed below are the plug-ins and their corresponding update sites.
Plug-ins (Necessary):
Plug-ins (Experimental/Evangelist): If you are the experimental type yearning to try out bleeding edge technologies, here are some plug-ins (some unstable) which can help.

Adding System Dependencies in Maven POM

When using Maven as a Project Management/Build System, the dependencies of a project should be available in either a local or a remote repository. But in some cases we might have dependencies on some arbitrary libraries which might not be part of any repositories.
If you have the library (.jar), you can specify a system dependency (good old ANT class path style) without even installing/deploying the libraries into your repositories.
Consider a maven project like this(in picture) where the dependencies(.jar) are maintained in a lib folder.
2009-09-21_123913
Here is how the dependencies are to be specified in the pom.xml. Note that ${basedir} is a maven system property to denote the base directory of the project.
<dependency>
<groupId>org.igniterealtime</groupId>
<artifactId>smack</artifactId>
<version>3.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/smack.jar</systemPath>
</dependency>
<dependency>
<groupId>org.igniterealtime</groupId>
<artifactId>smackx</artifactId>
<version>3.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/smackx.jar</systemPath>
</dependency>



Wednesday, September 16, 2009

How a Single Character screwed my day!

In today’s Java world, we are so engrossed into using build & project management tools like ANT, MAVEN etc that we seldom use the atomic JDK tools(java,javac…) directly. Yesterday was one of those days when getting back to basics kicked my butt.
The Premise
  • Me and my colleague created a very simple MAVEN+SPRING project with a Main Class.
  • Used maven-exec-plugin to run the Main class and things worked perfectly fine
    • mvn exec:java -Dexec.mainClass="com.foo.MainClass"
  • Then came the primitive idea of using java to run the application with all the dependencies in the classpath. And we Java Junkies know it right?
    • java -classpath "x.jar;y.jar" com.foo.MainClass
The Problem
  • For some reason the primitive idea of using java tool didn’t work.
  • We stared at each other. Tried again. And again with quotes “”, other misc changes. But still didn’t work.
The Solution
  • Culprit (;)
    • All this was done on a Linux Dev machine and we forgot to realize that the character ‘;’ is recognized as some mumbo jumbo(which I haven’t figured out yet) by bash/shell.
  • Savior (:)
    • After hours (consider man minutes) of researching the on Google, Tech forums, etc with lame key words, I resorted to look into some preinstalled java apps on linux and there it was – the solution to the misery, the light at the end of the tunnel, the answer to the problem, a savior in the form of a single character ‘:
    • Just erased the presence of the culprit ‘;’ and replaced it with the lord, the savior ‘:’ and Voila!, Eureka!, …. IT WORKED.
    • java -classpath "x.jar:y.jar" com.foo.MainClass
Tip/ Note/ Realization
  • Understand the OS specific execution paradigms
  • The classpath delimiter in Windows is ‘;’ and in Unix flavors, it is ‘:
  • Revisit the basics often
  • Shit Happens
And this is how Ladies & Gentlemen, a single character screwed my day… and here is a single page documented (wasted) for that !!