Results 1 to 4 of 4
  1. #1
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

    Default Question about creating jar file

    Hi all,

    I am trying to create a simple jar file, Hello.jar. However, I can't execute the Hello.jar. I got the following message, "Failed to load Main-Class manifest attribute from Hello.jar"

    First of all, I create two files:

    Hello.java
    Java Code:
    public class Hello {
        public static void main(String[] args) {
            System.out.println("Hello, world!");
        }
    }
    Hello.mf
    Java Code:
    Manifest-Version: 1.0
    Main-Class: Hello
    After that, I compile the Hello.java in cmd by typing
    Java Code:
    javac Hello.java
    to create the Hello.class

    Then, I type
    Java Code:
    jar cmf Hello.mf Hello.jar Hello.class Hello.java
    to create the jar file, Hello.jar

    And, I run it by
    Java Code:
    java -jar Hello.jar
    However, Message come out: "Failed to load Main-Class manifest attribute from Hello.jar"
    What is my problem? Can someone help me to figure it out?

    Hope someone can help me.
    Thank you.
    Last edited by hei1233212000; 10-26-2010 at 04:17 PM.

  2. #2
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

    Default

    can someone help me please?

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default

    Quote Originally Posted by hei1233212000 View Post
    Hello.mf
    Java Code:
    Manifest-Version: 1.0
    Main-Class: Hello
    "The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return."

    See: Modifying a Manifest File (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)

  4. #4
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

Similar Threads

  1. Question about creating a Game State Manager
    By nolsen01 in forum New To Java
    Replies: 1
    Last Post: 03-05-2010, 10:23 PM
  2. creating a file
    By aruna.hcu in forum New To Java
    Replies: 25
    Last Post: 01-06-2010, 06:15 PM
  3. Replies: 5
    Last Post: 12-21-2009, 01:17 PM
  4. Creating a .jar file
    By Wataru in forum New To Java
    Replies: 3
    Last Post: 07-22-2009, 06:02 AM
  5. Creating objects question
    By sergm in forum New To Java
    Replies: 2
    Last Post: 12-27-2007, 04:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •