473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

jar archive

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
Jul 17 '05 #1
2 5109
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.
Jul 17 '05 #2
> 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


Thanks, I got it working! I didn't know that for packages you need
indentical directory structure in manifest.

--
Kova
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Евгений Косенко | last post by:
Hi! I need to fresh a zip-archive using zipfile. However, it seems it is no function to fresh the archive. When I use the append-mode of ZipFile, the written file is merely appended to the...
1
by: labrach | last post by:
hye, I'm using Archive::Tar to create .tar.gz file on either Unix or Win32 boxes The archive is created with the class method : Archive::Tar->create_archive('test.tgz',9, @filelist); where...
1
by: DB2 Convert | last post by:
Hi, A few points to confirm as I am still new with DB2. 1. What will happen if archive logging is used, however there is no userexit or manual process to move those online archived logs to...
7
by: William | last post by:
I am using DB2 8.2 on RH Linux 8.0. I just compiled db2uext2.c but failed to archive the log files, did anybody fix this problem before? TIA db2diag.log 2005-06-12-12.39.52.305630-240...
0
by: Kate | last post by:
Hi... I have a foxpro program which is for producing excel reports back ended to foxpro table(.dbf). Since the table is getting bigger and bigger, it slows down my program. I need a program...
6
by: JezB | last post by:
From a windows application, I want to provide an "archive" facility which will scan a specific directory and put specific files into some single "Archive file", a bit like a zip-file I guess, but...
7
by: Enigma Curry | last post by:
I need to store a large number of files in an archive. From Python, I need to be able to create an archive, put files into it, modify files that are already in it, and delete files already in it. ...
3
by: Hallgeir Stuenes | last post by:
I'm trying to understand the differences between a XML document archive versus a relational data base. What are their advantages and disadvantages? - Hallgeir
1
by: dwainew | last post by:
Problem: I'd like to archive off the contents of a text file. However, other processes may have the file open, so MoveTo(newfilepath) can't be done, as far as I've found. Start with a 5 MB...
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.