Kova wrote:
Hello.
I wrote a program that I want to put in a executable jar archive. How do I
do that? Program has 2 classes in a package. I tried something like
"jar -cfv program.jar class1.class class2.class" but it I got error that
main class cannot be found. How can I specify the main class? Tnx.
Kova,
It sounds like you left out a few steps in the above description. I
assume you got the main class error when you tried to run the jar file.
To specify the main class, you use a manifest file. The manifest
contains an entry Main-Class whose value is the class you wish to invoke
when the jar is run. A simple manifest for the class com.xyz.Main would
look like:
Main-Class: com.xyz.Main
(NB: Put an empty line at the end of your manifest file. I've seen the
jar program skip the last entry if the blank line is missing!)
To create the jar with the manifest, use the m option:
jar cvfm program.jar my-manifest.mf com/xyz/Main.class
Note that the manifest file is placed in the jar under the enter
META-INF/MANIFEST.MF (although capitalization will differ depending on
the version of jar; UNIX guys love that feature).
If this doesn't help, please post more explicit instructions. Or you
could search the archives on Google, I've helped with this issue before
and please have posted very explicit stuff on what they did.
Ray
--
XML is the programmer's duct tape.