Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manifest of a Jar file

Status
Not open for further replies.

satellite03

IS-IT--Management
Dec 26, 2003
248
IN
hi, i want to know what is the role/job of a manifest file in a JAR package. what it does ?


can you plz show me some sample examples ?

thank you
 
It does a few things, for example - if the jar is "executable" - execute it by the "java -jar" syntax, then it hold the class name for the code that contains the main() method.

It also is used to sign classes as beans and so on.

Take a read of the jar file spec :


--------------------------------------------------
Free Database Connection Pooling Software
 
i visited the link. there are many things which are out of bounds.

>if the jar is "executable" - execute it by the "java -jar" >syntax,

are u sure ? . is it a typing mistake ? because i have seen to use java -classpath blah blah instead of java -jar blah blah ( whcih you mentioned )

or there are both way we can execute JAR ?

>then it hold the class name for the code that contains the >main() method.

good.


>It also is used to sign classes as beans and so on. [ponder]

sign ? what sign ? +,- ?

A jar can contain many classes . whats the sign about them !! [mad]
 
You can execute a jar file by doing :

java -jar myjarfile.jar

as long as the manifest contains an entry for a class that contains the main() method :

Code:
C:\Documents and Settings\user>java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

To "sign" something (such as signing a class as a bean in a manifest) is just a terminology for "identifying a resource as of a certain type".

--------------------------------------------------
Free Database Connection Pooling Software
 
>as long as the manifest contains an entry for a class that contains the main() method :

so, who does it ? Utility tool like WinZip or Jar command to create the JAR archieve do they put the main class in the manifest automatically ?

or do I have to write it manually in the manifest ?
 
satellite03 said:
do I have to write it manually in the manifest ?

That will certainly work...

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
You basically manually create a manifest file, and then add it in using the "jar" command - I suggest you read up on the jar command switches.

--------------------------------------------------
Free Database Connection Pooling Software
 
i found another solution
Code:
 java -classpath MyJarFile.jar MyMainclass

 
Well, that is the usual way of starting a Java program. You, however, were asking about Manifest files, hence sedj's replies.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
I'm confused ... you originally asked to know about the manifest file - not how to execute a jar file !

--------------------------------------------------
Free Database Connection Pooling Software
 
actually my question was not directional, i was confused (and was not sure ) to see there are many ways to run the jar file.

1. java -jar MyJar.jar

2. java -classpath MYJar.jar MyMainclass


so was my confusion and asked you about the confirmation . why there are so many versions to run a JAR file ? i found manifest is the culprit. so i asked the question on manifest. Hope u understand now.
 
satellite03 said:
why there are so many versions to run a JAR file ?

... because Sun is adding functionality to Java all the time, and older functionality is usually left in to keep things working.

satellite03 said:
actually my question was not directional

... actually, it looked quite directional to me. How are we supposed to know that there is a hidden question behind the one you posted. It's always a good idea to post the actual problem you want solving, rather than trying to lead people with 'side' questions.

Anyway, it's good that you now have the information you were after [smile].

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top