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 !!

Tuesday, August 18, 2009

Entering Linux World with VirtualBox

Though I have worked with Linux earlier, it hasn't been so intense as in my current job.
So I thought I would use Virtualization techniques to keep closer to my Desktop environment for my personal sandbox purposes.
I have chosen Sun VirtualBox & Ubuntu 9 Desktop to be my companions.

To achieve:
I have a Windows Vista PC and I want to install Ubuntu Linux as a Guest OS. In VirtualBox terms, the base OS is called a HOST and every new OS you want to virtualize(install) is a GUEST.
Basic Steps:
  1. Download & Install VirtualBox from http://www.virtualbox.org/
  2. Download Ubuntu ISO image from http://www.ubuntu.com/getubuntu/download
  3. Create a new Guest for Ubuntu on VirtualBox
  4. Load the ISO and install.
Virtual Box Additions:
  1. Load VBoxGuestAdditions.iso from VIRTUALBOX_HOME to the Guest and reboot.
  2. In the Guest Ubuntu, goto /media/cdrom0 and run VBoxAdditionsx86.run. This will install all the additions virtualization packages.
  3. You can make shared folders from host available to the guest either manually or during startup (http://www.giannistsakiris.com/index.php/2008/04/09/virtualbox-access-windows-host-shared-folders-from-ubuntu-guest/)
Java Env Setup:
Accessing Apps running on the Guest OS:

My very intention of installing Linux as a Guest OS was to try out it server features. That being the case, I wanted to run servers in the Guest OS(Linux) and make them available to the outside world via my Host OS(Windows).
For this instance, I have started ssh server and apache server on the server and wish to externalize them. Here is how you can do it.

C:\>  cd "\Program Files\Sun\xVM VirtualBox"
VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/cherokee/HostPort" 8888
VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/cherokee/GuestPort" 80
VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/cherokee/Protocol" TCP

VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata ubuntu-desktop "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP





References: http://imshengh.spaces.live.com/blog/cns!9F02E6E8FFC2ED09!379.entry

Friday, May 1, 2009

Digg .. Philosophical progress message.

Started using digg.com for sometime now and this progress message from the site is really philosophical.