Java Jar Manifest Problems...

Discussion in 'Trading Software' started by bungrider, Apr 1, 2004.

  1. what is up with java's JAR & manifest thing?

    ...i've got 1.42_04 "installed" in winblows 2kpro, and every time i try to launch a JAR "executable" in windows, i get the same error over and over again from the command line:

    Failed to load Main-Class manifest attribute from

    ..or some issue with the manifest file.

    is there something i'm missing or didn't install right?

    thanks in advance,
    -b


    PS - thanks, microsoft, for making java such a pain in the ass to run in windows...
     
  2. Error message is a little unclear, but the manifast file contains
    the name of the java class which has the main() function which
    is supposed to be executed to get the application running.

    Seems that value is missing so it doesnt know WHICH java class
    to start executing first.

    You can extract the manifest file using WinZip or like tool.
    Then you can read it and find out what class has the main() which
    is supposed to be executed.

    If this class does not exist in the jar file, thats the problem.

    Or, if there is nothing in the manifest file which specifies
    the starting class, thats the problem.

    peace

    axeman
     
  3. agrau

    agrau

    There are actually many possible problems that give unclear jar loading messages.

    Don't have any empty linei in your manifest file.

    But: Add at least one final empty line to your manifest. Or better yet a couple of empty lines.

    Don't add ".class" at the end of the Main-Class line. It's just: "Main-Class: a.b.c.YourClass" - not YourClass.class

    The Class-Path: line should precede the Main-Class: line.

    If you have sections: Move Main-Class: to the main section (don't leave it in Common)

    Make sure the arguments match the command switches for jar: "jar cmf manifest.mf something.jar *.class" or "jar cfm something.jar manifest.mf *.class"

    If all fails post your manifest file and the command you give to create the jar - we'll hunt that bug :)

    Best,
    agrau
     
  4. axe and agrau,

    thanks for your help...i'm new in java and getting frustrated with things like this which are actually very straightforward and sensical, yet are quite puzzling to the newbie...before this i'd been using C# with good success and i guess i didn't realize how easy MSFT makes things for people like me who are novices...

    for some reason, it seems like every JAR file that i download won't execute from the command line (windows) for a variety of reasons, and also won't execute (gives me the no main class line) when i double click the JAR file from the shell...for example, i downloaded the hypersonic database engine from sourceforge, and the jars didn't have a main class...so iwas quite confused...

    i also wrote a small app in jbuilder X and had trouble getting it to run until i set a main class in the manifest...

    what i should have done first is read the chapter in my java book on all this (which, incidentally is a great one to learn java from if any other newbies are out there looking for a great, detailed, intro to java book - i am using ivor horton's beginning java 2 sdk 1.4 and it is superb).


    thanks again for the help, gents...
     
  5. Didn't think that all JAR files are necessarily executable. Especially if you've downloaded a JAR containing some kind of utility code like a DB engine.

    I'm not a Java guru (use VB/ASP/C++/C# mainly), but can't a JAR just be a compressed library of JS files - used sometimes to streamline the download of a bunch of different JS script files for a web page. In such a case, there would be no "main" and the JAR would not be intended for direct launch and execution.