support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets
 

Veryant Knowledge Base
Home > All Categories > isCOBOL General > Deployment > How can I package my application and execute it in a JAR file?
Question Title How can I package my application and execute it in a JAR file?

Question:

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?

Answer:

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
Myproject
esourceimage1.bmp
and 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:
jar cfv myprog.jar -C Myprojectobject PROG1.class -C Myproject
esource image1.bmp 
or
jar cfv myprog.jar -C Myprojectobject . -C Myproject
esource . 
The dots tell JAR to include all files in the directories.

Then you would execute the program on Windows with:
java -cp "myprog.jar;c:program filesveryantiscobol2007libisrun.jar" PROG1 
or
set CLASSPATH="myprog.jar;c:program filesveryantiscobol2007libisrun.jar" isrun PROG1 
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.jar
The last line of the file should be a blank line.

Create the executable JAR file with the following command line:
jar cmfv MANIFEST.MF myprog.jar -C Myprojectobject . -C Myproject
esource . 
At run time make sure that isrun.jar is in the same directory as myprog.jar. Then you can execute your program by double-clicking on it (if your desktop file association is set correctly) or with the following command:
java -jar myprog.jar 
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 ctree-rtg.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.jar
You 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 This question has been viewed 14951 times so far.
Click Here to View all the questions in Deployment category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. How do I create a desktop shortcut icon to launch my program?
  2. What are the minimum files I need for a runtime-only installation? How do I create a launcher?
  3. How do I generate an executable for deployment?
  4. How do I create an installation package for my COBOL application?
  5. Can I mix versions of Java, isCOBOL compiler and isCOBOL runtime?
Article Information Additional Information
Article Number: 54
Created: 2009-08-31 5:54 PM
Rating: 1 Star
 
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
 
Search Knowledge Base Search Knowledge Base



 
 

© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.