mercredi 12 mars 2008

creating a executable wrapper for a java program.

Today I wanted to create a Windows executable wrapper around my java jar files. I find it more handy to create such an executable wrapper for daemon processes I want to add to my Windows "Startup" menu for example.

For that I used an open source program called launch4j (launch4j.sourceforge.net).

Here are the steps needed to create your own executable out of java jar files:

1) Make sure you have your main program jar file, any utility jar and resources files available in the same directory.

2) Make sure that your main program jar file's MANIFEST.MF file contains the following information:
Class-Path: *.jar
where *.jar is the list of jar files your main program needs and that should be in your classpath. For example in my case this was: Class-Path: nsclient4j.jar

Main-Class: PathOfClassContainingMainMethod
where PathOfClassContainingMainMethod is the name of the class that starts your program.
For example in my case this was:
Main-Class: net.sf.rcpperfmon.deamon.HostPerformanceStatsDeamon

3) Start Launch4j and fill these minimally needed information:
- output .exe name.
- main jar file containing the startup class.
- minimum jre version.

Once you press on the build button you should have your .exe correctly create as per the below figure.

Happy coding.....and wrapping.....


dimanche 9 mars 2008

RCP Performance Monitor

During the last couple of months I was intensively reading articles about and learning how to write RCP applications using the Eclipse Rich Client Platform technology.
In the process of learning, I managed to write a simple application (along with its accompanying server side daemon) that can be used to monitor CPU utilization of remote hosts over a network.

The code is hosted on http://code.google.com/p/rcpperfmon/ and is licensed under the LGPL.
Below is a screenshot of my application. I am very excited and happy that I managed to learn how to write Eclipse RCP apps and I am thinking about making a tutorial out of that application.

Keep posted...

Restoring GRUB boot menu from ubuntu live CD.

If windows overwrites your MBR you can boot into any ubuntu live CD and do the following from a terminal window. This happened to me today and the steps below solved my problem.

sudo grub
this will log you into GRUB, you should get a grub> prompt.

find /boot/grub/stage1
This will search for the location where grub is installed and will return a string of the form hd(?,?) which will be used in the next command.

root hd(?,?)
This will tell GRUB the correct location. Do not forget to replace the ? will the values returned frol the previous comand.

setup (hd0)
This will install GRUB on your MBR.

samedi 1 mars 2008

My first steps using the GIMP

Lately, I have been reading some tutorials about the GIMP (GNU Image Manipulation Program). The tool is really powerful and feature rich. One is only limited by their creativity while creating graphics or editing images with the GIMP.

Today, I stumbled across the following short tutorial

Using Gimp to make Web 2.0 Buttons and Graphics

And I managed to create a simple but really cool buttons for my web page. Below is a sample HTML page I crafted in 2 minutes.