Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Jar files not created/loading correctly

  Asked By: Hamish    Date: Sep 17    Category: Java    Views: 854
  

I try to run the created file I get this error:

Failed to load Main-Class manifest attribute from
C:\SimuConfig\Output\SimuConfig.jar

What does this mean? and how do I fix the error, I can't find anything on
this...

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Cay Nguyen     Answered On: Sep 17

You need to include a manifest file  which looks something like this:

Manifest-Version: 1.0
Class-Path: lib/somelib.jar
Main-Class: com.anthonyeden.MainClass



(Note: There must be a line feed after the Main-Class header.)

This file must be called MANIFEST.MF in the META-INF directory of your
JAR. You can find  more information on this if you look for information
about executable JARs.

 
Answer #2    Answered By: Corbin Jones     Answered On: Sep 17

The manifest which I described is for creating an executable jar  which
can be run  either by a.) double-clicking on it or b.) executing java
-jar MyJar.jar from the command line. I assume this is what you are
trying to do and cannot?

Anyhow, the Class-Path line in the MANIFEST.MF file  just tells the java
runtime binary what the main class is (i.e. a class which has the method
public static void main(String[] args)). This class name can be
anything with this method (I used com.name.MainClass as an example, but
it could be FooBar or anything else for that matter.) Note also that
you must be very careful with case and other little details:

1.) The manifest must be in your JAR as /META-INF/MANIFEST.MF
2.) The Class-Path line must be capitalized properly (capital C,
capital P)
3.) I believe that ordering may even be important
4.) There must be a return after the Class-Path line, even if it is the
last line in the manifest.

I am not sure how you are building your applications, but you may want
to take a look at Ant ( http://jakarta.apache.org/ant ), a build tool
from the Apache Jakarta group. Ant takes care of a lot of these issues
when creating JAR files.

 
Didn't find what you were looking for? Find more on Jar files not created/loading correctly Or get search suggestion and latest updates.




Tagged: