Link to home
Start Free TrialLog in
Avatar of balyon
balyon

asked on

Jar File Manifest

I am creating a jar file for an application that has several classes.  I created the jar file with the command "jar cf app.jar *.class".  When I try to run the jar file, I type in "java -jar app.jar" and I get the error
"Failed to load Main-Class manifest attribute from app.jar".  How do I either modify the manifest file to give it the attribute it wants or how do I create the jar file with the needed attribute?
Avatar of vladi21
vladi21

look
--
sun JAR tutorial http://java.sun.com/docs/books/tutorial/jar/index.html
---
JAR format http://developer.netscape.com/docs/manuals/signedobj/jarfile/jar.htm
http://java.sun.com/products/jdk/1.2/docs/guide/jar/manifest.html 
http://developer.java.sun.com/developer/Books/JAR/basics/manifest.html
Manifest files can contain arbitrary information about the files in the archive,
such as their encoding or language. If the JAR archive is intended for use with
the SmartUpdate feature of Communicator, the manifest file must include, at a minimum,
the address of the installation file
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/java.html

The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method. The method declaration must look like the following:
    public static void main(String args[])

The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. By default, the first non-option argument is the name of the class to be invoked. A fully-qualified class name should be used. If the -jar option is specified, the first non-option argument is the name of a JAR archive containing class and resource files for the application, with the startup class indicated by the Main-Class manifest header.
The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path.

Non-option arguments after the class name or JAR file name are passed to the main function.

ASKER CERTIFIED SOLUTION
Avatar of vladi21
vladi21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial