1 2 Previous Next 17 Replies Latest reply: Jun 5, 2008 2:26 PM by 807601 RSS

    my newest making a jar file attempt, need help please

    807601
      here is a second attempt. i used eclipse instead. and manually tried to make the jar file. when trying to make the jar, i got the error, "invalid manifest format".

      first, here is the code to the program

      // Manually allocate differing size second dimensions.
      class Ragged {
      public static void main(String args[]) {
      int riders[][] = new int[7][];
      riders[0] = new int[10];
      riders[1] = new int[10];
      riders[2] = new int[10];
      riders[3] = new int[10];
      riders[4] = new int[10];
      riders[5] = new int[2];
      riders[6] = new int[2];
      int i, j;
      // fabricate some fake data
      for(i=0; i < 5; i++)
      for(j=0; j < 10; j++)
      riders[i][j] = i + j + 10;
      for(i=5; i < 7; i++)
      for(j=0; j < 2; j++)
      riders[i][j] = i + j + 10;

      System.out.println("Riders per trip during the week:");
      for(i=0; i < 5; i++) {
      for(j=0; j < 10; j++)
      System.out.print(riders[i][j] + " ");
      System.out.println();
      }
      System.out.println();
      System.out.println("Riders per trip on the weekend:");
      for(i=5; i < 7; i++) {
      for(j=0; j < 2; j++)
      System.out.print(riders[i][j] + " ");
      System.out.println();
      }
      }
      }

      now here are the contents of my manifest.mf file i tried to put the manifest.mf file and ragged.class file in the jar.

      Manifest-Version: 1.0
      Ant-Version: Apache Ant 1.7.0
      Created-By: 10.0-b22 (Sun Microsystems Inc.)
      Main-Class: Ragged.Ragged
      Class-Path: .\Ragged.jar
      silverglade
      Posts:48
      Registered: 5/24/08 Re: if the user cant double click open my jar file, whats the point of maki
      Jun 5, 2008 11:42 AM (reply 43 of 43)



      i changed the manifest to this and it still got the same error when i tried to make the jar

      now here are the contents of my manifest.mf file

      Manifest-Version: 1.0
      Ant-Version: Apache Ant 1.7.0
      Created-By: 10.0-b22 (Sun Microsystems Inc.)
      Main-Class: Ragged
      Class-Path: .\Ragged.jar
        • 1. Re: my newest making a jar file attempt, need help please
          807601
          49 posts and you have no idea what code tags are or why you would want to use them? No soup for you.
          • 2. Re: my newest making a jar file attempt, need help please
            807601
            if you dont feel like helping, dont bother posting, this is the new to java forum
            • 3. Re: my newest making a jar file attempt, need help please
              807601
              Don't use System.out.println -- there is no console to output to when you run this jar by double-clicking on it.

              I suggest, if you are still not able to get an executable jar to work, to concentrate on a one line program: JOptionPane.showMessage...
              • 4. Re: my newest making a jar file attempt, need help please
                807601
                How about you do what we've suggested to this point, and not use eclipse OR netbeans? Use the command-line utilities.

                [http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html]

                You just gave up when we suggested this last time, because the executable "jar" wasn't on your path. That's fine, just fully qualify the name. For example, mine might be like this:
                C:\Program Files\Java\jdk1.6.0_02\bin\jar.exe cmf Manifest.MF Ragged.jar Ragged.class
                • 5. Re: my newest making a jar file attempt, need help please
                  807601
                  nvm

                  Edited by: prigas on Jun 5, 2008 12:27 PM
                  • 6. Re: my newest making a jar file attempt, need help please
                    807601
                    silverglade wrote:
                    if you dont feel like helping, dont bother posting, this is the new to java forum
                    It would be naive to think that he wasn't helping. He was suggesting you post the code in
                     tags.  That's one of the most useful pieces of advice you'll find here, because many of us will ignore posts which include unformatted code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                    • 7. Re: my newest making a jar file attempt, need help please
                      807601
                      i guess is will wait until i am familiar with swing.
                      • 8. Re: my newest making a jar file attempt, need help please
                        807601
                        instead of telling me what a code tag was, he insulted me and said no soup for you. or did he assume i know what a code tag is.
                        • 9. Re: my newest making a jar file attempt, need help please
                          807601
                          if my class is Ragged.class, and manifest.mf, is the following manifest. correct?

                          Manifest-Version: 1.0
                          Ant-Version: Apache Ant 1.7.0
                          Created-By: 10.0-b22 (Sun Microsystems Inc.)
                          Main-Class: Ragged
                          Class-Path: .\Ragged.jar

                          i am able now to make the jar file but it doesnt work in the command prompt or double click. it gives the error, "Failed to load Main-Class attribute from Ragged.jar"
                          • 10. Re: my newest making a jar file attempt, need help please
                            807601
                            silverglade wrote:
                            if my class is Ragged.class, and manifest.mf, is the following manifest. correct?

                            Manifest-Version: 1.0
                            Ant-Version: Apache Ant 1.7.0
                            Created-By: 10.0-b22 (Sun Microsystems Inc.)
                            Main-Class: Ragged
                            Class-Path: .\Ragged.jar

                            i am able now to make the jar file but it doesnt work in the command prompt or double click. it gives the error, "Failed to load Main-Class attribute from Ragged.jar"
                            Did you make that from the command line, eclipse, or netbeans?

                            Do what I've already said. Create it from the command-line. Only include the Manifest-Version line and Main-Class line. Don't include anything else in your manifest file.
                            • 11. Re: my newest making a jar file attempt, need help please
                              807601
                              i made the jar from the command line, and the contents of my manifest.mf is

                              Main-Class: Ragged
                              Class-Path: .\Ragged.jar


                              my class is Ragged.class.

                              and i still get the error "Failed to load Main-Class manifest attribute from Ragged.jar" from the command line when i run it, and same when i double click it.
                              • 12. Re: my newest making a jar file attempt, need help please
                                807601
                                If you had read the link provided to the documentation for "jar" you would have seen the following information:
                                Be sure that any pre-existing manifest file that you use ends with a new line. The last line of a manifest file will not be parsed if it doesn't end with a new line character.
                                I can almost guarantee that's your problem if you're trying to create the jar file by hand at this point, as I can simulate the exact same problem you're having by not having a newline at the end. All your manifest needs is:
                                Manifest-Version: 1.0
                                Main-Class: Ragged
                                and away you go. Now please, even though I've provided the answer, go read the documentation that everyone else has provided. It will assist you immensely.

                                ~mroessing
                                • 13. Re: my newest making a jar file attempt, need help please
                                  807601
                                  Maybe you should set executable jars aside for a while. They're really not a Java programming topic, more of a "can you follow instructions" topic, and you seem to be stuck. Do something else.
                                  • 14. Re: my newest making a jar file attempt, need help please
                                    807601
                                    i think youre right, im impatient as hell, and i wanted other people to be able to use my programs, but for now i guess i will wait until i go to school for programming, and figure it out then. i tried everything everyone said and still im having problems, youre right, im stuck, im just going to forget about it until i go to school . thanks everyone for trying to help me. derek
                                    1 2 Previous Next