aspose file tools*
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
Author

JAR File

ABC DEF
Greenhorn

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 manifest.mf 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: 1135

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:
http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/jar.html
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,
Avi.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
ABC DEF,
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
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You may want to take a look at Creating a JAR File.
 
 
subject: JAR File