|Title: How can I package my application and execute it in a JAR file?|
How do I package my application with resources in a JAR file?
How do I run a program that is in a JAR file?
How can I create an executable JAR file so that the user can just double-click on it?
The Java Archive Utility, JAR for short, is what you use to combine multiple files into a single file in order to simplify distribution and deployment. It replaces the functionality you used to get with Acucorp’s cblutil.Â
You can also use jar as another solution for helping your application to find resource files such as bitmap images.Â
For example, suppose you had the following file structure:
MyprojectobjectPROG1.class Myprojectresourceimage1.bmpand you wanted to package it all into a single file. If your W$BITMAP loads “image1.bmp” then you could put PROG1.class and image1.bmp into a JAR file with:
The dots tell JAR to include all files in the directories.Â
Then you would execute the program on Windows with:
When you are ready to package your application for distribution you can combine all necessary class files and resources into one JAR file and create what is known as an executable Jar. Then double clicking on the .jar file will execute your application. Or you can execute it with simply “java -jar executable.jar”
To do this you create a manifest file. For example, in the above example, create a file named MANIFEST.MF with the following contents:
Main-Class: PROG1 Class-Path: isrun.jarThe last line of the file should be a blank line.
Create the executable JAR file with the following command line:
At run time make sure that isrun.jar is in the same directory as myprog.jar. Then you may execute your program by double-clicking on it (if your desktop file association is set correctly) or with the following command:
If desired, you can put isrun.jar and other isCOBOL JAR files that your application uses in a subdirectory. For example if your application needs both isrun.jar and coblib.jar then you could put those in a subdirectory named iscobollib. Then you add this subdirectory name to the JAR files in the MANIFEST.MF Class-Path. For example, with the following installation file structure:
apps/myapp/myprog.jar apps/myapp/iscobollib/isrun.jar apps/myapp/iscobollib/coblib.jarYou would create the following MANIFEST.MF file:
Main-Class: PROG1 Class-Path: iscobollib/isrun.jar iscobollib/coblib.jar(separate URLs in Class-Path with spaces and end the file with a blank line)
|Authored by: Veryant Support on Mon, Aug 31st, 2009 at 7:00 PM
This question has been viewed 9881 times so far.
|Online URL: http://support.veryant.com/support/phpkb/question.php?ID=54|
Powered by PHPKB Knowledge Base Software