Failed to load Main-Class manifest attribute from Hello.jar???

HI all
This is my first post, I hope its in the right section
I followed the tutorial on [http://www.cs.princeton.edu/introcs/85application/jar/jar.html|http://www.cs.princeton.edu/introcs/85application/jar/jar.html] and I tried out the simple example below
A simple example. Let's say we wanted to distribute the simple program Hello.java as a JAR. First, we create a text file named Hello.mf which contains:Manifest-Version: 1.0
Main-Class: Hello
Then, we create the archive by typing:
jar cmf Hello.mf Hello.jar Hello.class Hello.java
and run it by typing:
java -jar Hello.jar 
But when I ran the command java -jar Hello.jar the following error message showed on my command prompt
Failed to load Main-Class manifest attribute from Hello.jar
I don't know what I have done wrong, i followed the tutorial to the letter.
Can anyone shed some light on whats going wrong please?
Many thanks
HLA91

Sorry about double post but i dont know whether editing my first one will bump the thread, and i need it bumped :).
I downloaded netbeans and I built my project and a jar file was created in oblong/dist (oblong is my project name) but again when i try to run the file the warning
Failed to load Main-Class manifest attribute from oblong.jar
appears and I dont know what i can do this time seen as i dont make the manifest file (read prior posts to see what i previously did wrong) , the compiler does it all for me so either im missing something that i have to do before building my project or netbeans is messing up for some strange reason. Can anyone provide insight?
Many thanks
HLA91

Similar Messages

  • Failed to load Main-Class manifest attribute from IWS.jar

    I have a problem that when I click the IWS.jar in dist folder, there is an error
    "Failed to load Main-Class manifest attribute from IWS.jar"
    i have search in internet with same case, they said to add a line
    "Main-Class: summary" in manifest.mf, so i have extract the .jar
    and open the manifest.mf file, but it said that main class will add automatically
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
    X-COMMENT: Main-Class will be added automatically by buildI am using Netbeans1.4 and jdk1.5.0_06 to create java application.
    How should I fix it?
    Thanks

    Thanks for the reply..
    I have fix it.
    Actually why I got the error is because I used panel form to create GUI form.
    So I try create new file using frame form rather than panel. It will generate this main class.
    public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        } Thats why my .jar fail to load when I used panel form because its does not have main class in it.

  • Failed to load Main-Class manifest attribute from HelloWorld.jar

    Hi,
    I got a file call HelloWorld.java and a file call mainClass which contain one line ==>
    Main-Class: HelloWorld
    Then I run the command:
    jar cmf mainClass HelloWorld.jar HelloWorld.class
    java -jar HelloWorld.jarAnd I got the following error:
    =======================================
    Failed to load Main-Class manifest attribute from
    HelloWorld.jar
    =======================================
    Why is that? I follow the instruction from the sun website, but still not working... can anybody help??
    Thanks

    For whatever reason the last line of the Manifest file is always ignored. So if your Main-Class is the first AND last line it is being ignored. Solution, make sure you have at least one or more blank lines after the Main-Class line.

  • Failed to load Main-Class manifest attribute from oc4j.jar

    Hi All
    I am trying to start OC4J in the SOA suite from the command line but every time i issue the command i.e.
    java -jar ORACLE_AS_HOME/j2ee/home/oc4j.jar
    I get the fololwing error
    "Failed to load Main-Class manifest attribute from oc4j.jar"
    I have checked the oc4j jar and the class oracle.oc4j.loader.boot.BootStrap does exits and it does have a main class
    Is the Manifest file broken?
    Does anyone know why this is happens?

    Hi,
    did you try the SOA Suite forum ?
    SOA Suite and OC4J 11g Technology Preview
    Frank
    Edited by: Frank Nimphius on Jan 30, 2009 1:41 PM

  • Failed to load Main-Class manifest attribute from test.jar

    Hi,
    I built a console application, there is a manifest.mf file which has Manifest-Version: 1.0 only.
    When I run C:>java -jar test.jar
    It showed
    Failed to load Main-Class manifest attribute from test.jar
    How should I fix it?
    Thanks

    Hi,
    I read
    http://java.sun.com/docs/books/tutorial/jar/basics/run.
    tml
    and do jar cmf mainClass app.jar HelloWorld.class on
    console window.
    Since my application is packaged like
    com.java.forum.HelloWorld, I changed it to
    jar cmf mainClass app.jar
    com.java.forum.HelloWorld.class
    It returned an error: java.io.FileNotFoundException:
    mainClass
    How should I do it?
    When you read that page, did you also read the link to Modifying a Manifest File? The mainClass that you specified should have been a text file that contains something like
    Main-Class: HelloWorld
    The FileNotFoundException indicates that the jar.exe program could not find a file named mainClass in the current directory. I can't help you with JBuilder or Eclipse.

  • Failed to load Main-Class manifest attribute from TextEditor.jar

    Hi, I'm trying to make a JAR file containing a Java application that I can run by double-clicking under windows.
    Everything works fine, except I get the error "Failed to load Main-Class manifest attribute from TextEditor.jar"
    I have tried to set up my manifest file to contain the Main-Class attribute. Eg:
    Manifest-Version: 1.0
    Main-Class: texteditor/TextEditorClass.classBut I get the error:
    java.io.IOException: invalid manifest formatIf I include a Name: header...
    Manifest-Version: 1.0
    Name: texteditor
    Main-Class: texteditor/TextEditorClass.class...then the manifest is used, (and I can even see my Main-Class attribute within the JAR), but if I double-click the JAR or use "java -jar TextEditor.jar" from an MSDOS prompt, then I still get the error message "Failed to load Main-Class manifest attribute from TextEditor.jar"
    I am using Java version "1.2fcs" Classic VM (build JDK-1.2fcs-S, native threads)
    How do I get the mainfest to accept the Main-Class attribute?
    thanks,
    Tim

    Thanks for the reply Kurt.
    Unfortunately I still get the same error. I have actually tried all sorts of combinations of the file with and without "Name:" and with and without .class.
    I must admit I never tried it with the Name line second like you showed, but I have now, and it gives me the same old "invalid manifest format" message.
    I was wondering if somehow I've ended up with an old version of JAR that cannot handle the Main-Class attribute. The problem is that unlike JAVA, JAR won't tell you what version it is. Any ideas how I might prove I'm running the latest version of JAR? Mind you, I get the same problem at home and at work, and my work version is the latest GenRel one so I think this is pretty unlikely.

  • Error: Failed to load Main-Class manifest attribute from HelloWorld.jar

    Hi,
    I got a file call HelloWorld.java and a file call mainClass which contain one line ==>
    Main-Class: HelloWorld
    Then I run the command:
    jar cmf mainClass HelloWorld.jar HelloWorld.class
    java -jar HelloWorld.jarAnd I got the following error:
    =======================================
    Failed to load Main-Class manifest attribute from
    HelloWorld.jar
    =======================================
    Why is that? I follow the instruction from the sun website, but still not working... can anybody help??
    Thanks

    For whatever reason the last line of the Manifest file is always ignored. So if your Main-Class is the first AND last line it is being ignored. Solution, make sure you have at least one or more blank lines after the Main-Class line.

  • Error message: Failed to load Main-Class manifest attribute from local_poli

    OS: SLED 10 SP3 (Linux)
    Production Installation: to have the freebXML.org "Hermes2" work on nhn.no
    Hermes, apache-tomcat, jce, are all installed in same directory, and the first steps of Hermes installation is OK, but I cannot reach Hermes in http://localhost:8080, and I wonder if the JCE is part of this.
    I need to have the JCE Ecryption Extension installed, but upon trying <java -jar local_policy.jar> the error message comes like this:
    *" Failed to load Main-Class manifest attribute from local_policy.jar "*
    I am uncertain why this message comes.

    816248 wrote:
    >I need to have the JCE Ecryption Extension installed, but upon trying <java -jar local_policy.jar> the error message comes like this:
    *" Failed to load Main-Class manifest attribute from local_policy.jar "*
    I am uncertain why this message comes.
    I'm uncertain why you think you need to execute "java -jar local_policy.jar" since the jar file local_policy.jar has no executable parts and is simply a container for two 'policy' files. Can you post a reference to the documentation that says you need to do this?
    The only time you are likely to be directly interested in this jar file is when installing the 'unlimited strength' jar files when it is replaced.

  • Please help me Urgent...Failed to load Main-Class manifest attribute from..

    *When i double clicked on any jar file showing an error like: {color:#ff0000}Failed to load Main-Class manifest attribute from....jar{color}*
    Can any one please suggest me a way rectify this error.
    Thanks in adv,
    -VNath

    Edit the deployment profile with the "Settings" context menu option and then under "JAR Options" make sure "Include Manifest..." is checked and then put the main class in "Main Class". Example: com.foo.myapp.Application1
    Rob

  • Failed to load Main-Class manifest attribute from

    hi all
    i created jclient swing based one form. and in this form i use BC4j and database employee table. when i run this java file from jdeveloper it works fine. when i deploy this project in simple archive jar file it gives me the above error. my application structure is this.
    workspace
    project1 (BC4j)
    project2 (my java file)
    i select project2 and do the deployment process. after creating jar file i use the following command.
    java -jar myapp.jar
    it gives me the following error
    "Failed to load Main-Class manifest attribute from"
    can any body help me out
    Thanks in Advance

    Edit the deployment profile with the "Settings" context menu option and then under "JAR Options" make sure "Include Manifest..." is checked and then put the main class in "Main Class". Example: com.foo.myapp.Application1
    Rob

  • Failed to load Main-class manifest attribute from jarfile

    Hi there,
    i am having problem to execute a jar file in command line (DOS). firstly I jar the files by using command line.
    1 - c:\jack> jar cfv myJar.jar Test
    myJar.jar file and Test folder are located in jack folder in c drive.
    then
    2 - c:\jack> jar tf myJar.jar
    display the following:
    META-INF/
    META-INF/MANIFEST.MF
    Test/
    Test/....class
    Test/....class
    then
    3- c:\jack> java -jar c:\jack\myJar.jar
    failed to load Main-class manifest attribute from myJar file.
    what should i do? did i miss any step??
    someone please help....

    Hi,
    You should declare the main class within you JAR file. This declaration is done into the manifest file or by specifying a particular swithch before you bild the JAR archive.
    For more information you can refer to the java tutorial regarding JAR tool "http://java.sun.com/docs/books/tutorial/jar/"
    Ferad Zyulkyarov

  • Failed to load main-class manifest attribute from jar files....

    Hi,
    I installed Java1.5 version in my system before to that Java1.6 was installed and uninstalled. When i i double clicked on any jar file getting a message like: Failed to load main-class manifest attribute from<name of the jar file>.jar file....
    can anyone please suggest me how to rectify this error.

    mvnath wrote:
    The jar files are worked before the installation of 1.5 but not after installation of 1.5I am guessing that the Windows file association for .jar somehow got munjed. It's hard to say since you have not provided much information.

  • "Failed to load main class manifest attribute from " directory path

    i get this error when trying to run a jar file i made with eclipse. does anyone know how to fix it? thanks derek
    "Failed to load main class manifest attribute from "<directory path>

    A JAR file is simply a collection of class files, in order to make it an "executable" JAR file you must specify which class file is the "main" class file. In other words, which class should the runtime start executing first. You do this using what is called a manifest file, this is meta information included into the JAR file that the runtime extracts and uses. One attribute is the Main-Class key, which specifies the application's entry point.
    The Java tutorial goes into further detail on how to do this
    http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
    You may also do this using Eclipse by going File -> Export -> Java -> JAR and follow the wizard.
    Using Netbeans this almost comes for free.

  • Failed to load Main-Class manifest attribute from apex.war

    Hi ,
    I m getting following error when i issue java -jar apex.war help setup
    Failed to load Main-Class manifest attribute from
    apex.war
    Could any one help me on it.
    Thanks

    You have exhausted my knowledge on this subject. Heap space sounds of java versions, memory allocations, operating system and hardware considerations that I can not help you with remotely.
    I have run the same command in a Linux VM that has 1 GB ram (quite small) and it runs as expected.
    Only thought I have would be to - check permissions on the files and directories you are working in.
    --Tim St.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Failed to load Main-Class manifest attribute from jar

    I get this error when i try start a executable jar file:
    Failed to load Main-Class manifest attribute from
    even though i have a
    Main-Class: a.b.c.MyClass
    entry in the meta-inf/manifest.mft
    I also have a (rather long) "Class-Path:" entry preceeding the "Main-Class:" entry in the manifest. What's wrong?

    ant has a major problem with very long "Class-Path" entries in a manifest file.
    The ant manual states, that jars wrap lines in manifest files longer than 72 characters. They say it's not their fault, and they can't do anything about it...
    I need to make an executable jar file with a classpath of approx. 200 characters.
    When i use Netbeans to jar the project, everythings fine.
    But using ant, the Class-Path seems to get messed up and none of the external classes are found, even though the manifest looks just like the one generated by Netbeans and the jar contents are the same.
    One way to workaround this problem is by using a manifest like this:
    Class-Path: some.jar foo.jar
      someother.jar
      guesswhat.jar
    Main-Class: what.everPlease take note of the leading spaces on the second and third Class-Path line.
    But i don't think, there's any way to make ant create a manifest like that using the ant <manifest> tag, because you can only specify a single "Class-Path" attribute, empty attributes are not allowed and if you use ${line.separator} to break lines, the line will still get a hard break after 72 characters. D'uh!
    Looks to me like a case of denial.
    On the other hand, there's another good idea to be found at jakarta:
    http://jakarta.apache.org/commons/sandbox/hivemind/jakarta-hivemind/ant/ManifestClassPath.html
    I'm going to check tomorrow if this might solve the problem.
    Or is there some other magical ingredient missing in the ant generated jar, that the NetBeans generated jar has??
    The most interesting part is, that i can't even make the ant jar run properly, if i call
    java -classpath ... -jar myAnt.jar

Maybe you are looking for