Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default Can't make a java .class to a .jar

    When I try to run the java1.jar it throws me this error: Failed to load Main-Class manifest attribute from c:\Java\java1.jar

    the java1.java contains this code:

    <code>
    import javax.swing.*;
    public class java1

    {

    public static void main(String[] args)
    {
    JOptionPane.showMessageDialog(null,"hi");
    }

    }
    <code>
    I use javac java1.java to compile it and it creates java1.class without errors
    then I use the command: "echo Main-Class: java1>manifest.txt"
    to create the manifest and finally I use the command: "jar cvfm java1.jar manifest.txt java1.class" to make the java1.jar but when i try to run it throws: "Failed to load Main-Class manifest attribute from c:\Java\java1.jar"

  2. #2
    glina126 is offline Member
    Join Date
    Feb 2011
    Posts
    28
    Rep Power
    0

    Default

    just to fix the code use this, but without spaces! [code] your code here [/ code] ;) its hard to read otherwise

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,569
    Rep Power
    12

    Default

    then I use the command: "echo Main-Class: java1>manifest.txt"

    It might be more straight forward to use a text editor to create manifest.txt rather than wrestling with echo. Either way the mainfest file must end in a new line or carriage return as described in the Setting an Application's Entry Point section of Oracle's Tutorial.

    (And the class should really be called Java1 as Java classes start with a capital letter.)

  4. #4
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by pbrockway2 View Post
    It might be more straight forward to use a text editor to create manifest.txt rather than wrestling with echo. Either way the mainfest file must end in a new line or carriage return as described in the Setting an Application's Entry Point section of Oracle's Tutorial.

    (And the class should really be called Java1 as Java classes start with a capital letter.)
    Don't know if it was the java1 to Java1 with caps or the manual writing of Main-Class: classname in the .txt but it works now. Thanks a lot!!!

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,569
    Rep Power
    12

    Default

    You're welcome.

    Given your screen name, I'm inclined to believe the use of proper naming conventions found favour with some higher forces.

Similar Threads

  1. Deleted Class template code. Now I cant make class.
    By AcousticBruce in forum IntelliJ IDEA
    Replies: 0
    Last Post: 01-11-2011, 11:52 PM
  2. How can I make this Java class work
    By ruchir123 in forum New To Java
    Replies: 2
    Last Post: 12-11-2010, 12:53 AM
  3. How to make my download class faster
    By pietertje in forum New To Java
    Replies: 3
    Last Post: 08-07-2010, 12:19 PM
  4. Hints on how to make a Java Class
    By luron31 in forum New To Java
    Replies: 11
    Last Post: 07-09-2009, 06:31 AM
  5. Please help, need to make my class static.
    By sumak in forum New To Java
    Replies: 1
    Last Post: 04-19-2008, 08:29 AM

Tags for this Thread

Posting Permissions

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