Monday, April 6, 2009

Trouble deploying Java apps on different machines?




Ok here is my story .
I am completing my M.Sc. thesis on IP Multimedia Subsystem at University of Tuzla, and have been working on an application that fits inside OpenIMSCore , a core implementation of an IMS network kindly provided by folks at Fraunhofer FOKUS institute. 

So far so good, I have developed my core engine (more on that in my next post) to interact with SCSCF and HSS , and everything worked like a charm  on my Linux testbed . My mentor okayed it , and we agreed that I should press forward with GUI design and writing the actual text of the thesis. 

So last night I fire up my all-time-all-languages favorite IDE, NetBeans (curr.version 6.5) and start designing the GUI . 

Add a checkbox here, add event handler there, wow that was really smooth (I can still remember the pains of developing GUI for Java 1.1 and 1.3 apps). Anyway, I pretty much completed the barebones stuff I wanted in about 30 mins, and have deployed it on a virtual Linux machine where my NGN OpenIMSCore is installed and configured to work with my Core Engine stuff. I start the app, and get one of those missing libraries errors :

Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group

After attempting to recompile with additional set of libraries which didn't work as expected, I started digging into the GUIs code. It turns out the problem was a simple one .
You see when you design GUI in NetBeans, the layout mode selected by default is the one called "Free Design" . It adds the code to group your GUI components into GroupLayouts which will work perfectly if you are going to run the app from within NetBeans or on the same machine, as the dependencies will already have been properly set for you.

If you however want to make your GUI app portable, and do not have the time to mess with setting up library dependencies into your project, or on the other machine, just  right click on the frame and select a different layout option . 

I found it that AbsoluteLayout works best for me as it requires no extra GUI dependencies and is likely to work on most machines with standard Java 1.5 and above installed.
Caveat : This is a quick solution , and I am not suggesting it as absolutely correct and the only true way, so don't bash me because of that :) 

Let me know how you normally cope with that.

Up next : My core engine in OpenIMSCore, and it what does !



No comments:

Post a Comment