File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes JAR File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAR File" Watch "JAR File" New topic

JAR File


Joined: Jan 01, 2003
Posts: 1
Hello! to All,
When I run the ".jar" file using:
java -jar abc.jar
The following error appears:
Failed to load Main-Class manifest attribute from abc.jar.
I updated the file in the META-INF
folder of the abc.jar file, like that:
Manifest-Version: 1.0
(I added)
Main-Class: RF2
(Note: RF2 is the name of the class which contains the main() method, i.e, the applications entry point).
But, nothing happend.
Any advice will be regarded very very valueable.

Thanks a lot to everybody!
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Hi ABC (or is that DEF?),
I didn't find any mention of JDK version or platform in your post, so I'm going to assume 1.4.1 on Windows, and refer you to the relevant documentation:
I'm also assuming that the "RF2" class is in the default package (i.e. _not_ in any package).
First you need to create a text file and put the following line in it:
Main-class: RF2
Note that you need to write it exactly as it appears above, and have an "empty" line after it (in other words, hit the <ENTER> key after typing the above line).
So, to re-iterate, open "Notepad" (since you are using Windows), type the line shown above, hit <ENTER>, and save the file (under any name you like).
Then create the JAR file. I don't know exactly what command you are using (since you didn't mention that, either), but it should start like this:
jar cmf myManifestFile abc.jar <rest of command...>
where "myManifestFile" is the file you created in "Notepad" (see above) and "abc.jar" is the name of the JAR file you wish to create. [Note: this assumes that "myManifestFile" is in the current directory.]
Et voila, you should now be able to (successfully) execute the following command:
java -jar abc.jar
Hope this has helped you.
Good Luck,
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
You may want to take a look at Creating a JAR File.
I agree. Here's the link:
subject: JAR File
It's not a secret anymore!