Wednesday, October 19, 2005

Executable Jar File in JAVA.

Creating an executable jar file is not that tough if it does not involve any external jars. Create a manifest file and mention the main class path in the manifest file. Place all the class files in a folder along with the manifest file and run the following command:

jar -cfm [name of the jar file] [name of the manifest] *

Flags Description:
c: Create new archive
f: Specify the archive name
m: include manifest

* means include all the files in the current folder and all the sub folders.

The manifest file look something like this:

Main-Class: [name of the main class along with the package details]


Example
If your project has two files a.class and main.class. which are placed in a package(abc.def). Then the manifest would look like this(mainClass.mf):

___________________
Main-Class: abc.def.main
___________________

and the command to create an executable jar will be

jar -cfm test.jar mainClass.mf *

Everything works ok if you are not using any external jars but the problem arises when you have externals jar like you have used the logging component log4j. The manifest attribute Class-Path attribute in which you can mention the paths of the external jars, but i tried it for log4j but it didn't work it gives me error 'Logger Class Def Not Found'. I had created the following manifest for that (Keeping the above exapmle in mind)

__________________
Main-Class: abc.def.main
Class-Path: lib\log4j.jar
__________________

but this didn't worked.

Then i came across a work around for this, which is you create a jar file of your project class files without adding the extenal libaries ie. using the following same manifest:

___________________
Main-Class: abc.def.main
___________________

Place the created jar files along with the external jar files in another folder and then use the following manifest to create the final jar file.

____________________
Main-Class: abc.def.main
Class-Path: main\test.jar lib\log4j.jar
____________________

Notice that test.jar is the jar file of your actual project. the final jar created using the above manifest will work for you.

Thursday, October 13, 2005

Camps & Medicines are needed more than anything else, Pakistan Intl. Airlines will carry donations for free.

As you may already know, the disaster that struck Pakistan's Kashmir and NWFP areas has left at least 40,000 dead and 2.5 million homeless (full stats are not in yet, many areas are not accessible at all because of damaged roads due to landslides), there is dire need of clothes, food items, medicines and camping equipment for the survivors.

http://news.google.com.pk/news?hl=en&ned=us&ie=UTF-8&q=earthquake+toll+40%2C000&btnG=Search+News


The winter has arrived and rain and hailstorms have severely hurt the rescue efforts. Please ask your local volunteers to collect as many donations as possible.

Lot of people in Pakistan are collecting donations and lots of cargo trucks, airplanes and helicopters have been dispatched to the affected areas, but the most important items that are short in supply are camps. No more camps are available in and around Lahore, and manufacturers have order for thousands of camps, but they won't be ready for many days.

2.5 million (possibly many more) people are left with no shelter, which means at least half a million camps are required.

The best thing would be to purchase camping equipment and medicines and send them to Pakistan, preferably Islamabad (because Islamabad is the closest big city, 95 km from Muzaffarabad, the epicenter) or Lahore (another 300km from Islamabad) because even with all the monetary aid, camps are not available here at all.

Pakistan International Airlines (PIA) will carry all relief goods for free from all of its stations in its global network ( http://www.piac.com.pk/press_release/pr293.asp)

Here are the url's of PIA's booking offices around the world alphabetized by cities:

http://www.piac.com.pk/b_offices/A.asp

(New York, Chicago, Houston in USA, Toronto in Canada)

List of PIA's worldwide Stations by Countries:

http://en.wikipedia.org/wiki/Pakistan_International_Airlines#Services

Links for online Donations: http://forums.anandtech.com/messageview.aspx?catid=38&threadid=1708958&enterthread=y

Please take action as quickly as possible, because the winter is here and the survivors are looking forward to our help. Feel free to contact me for any more information you need.

Thank you.

Thursday, October 06, 2005

DotNet Framework & IIS installation order

If you ever install the dot net framework before the IIS, then your aspx pages would not work. The solution to this problem is that:

open the command prompt [For windows Xp and greater]
>>cd C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
>>aspnet_regiis.exe -i

In case you are using any other windows then search the aspnet_regiis.exe file and run this file from the command prompt with -i argument.

Note: Today one of my friend asked me about this problem and he told me that he is unable to find any solution of this problem on the net, so i though of publishing it on my blog. Hope it will help many.