Hello All, I have this folder which holds my java class called apple, a text file called mainclass (which holds this: Main-Class: apple) and I have a jar file called apple aswell. when I go to run the jar file to see the output I get this error: C:\j21work\I>java -jar apple.jar Failed to load Main-Class manifest attribute from apple.jar what have I done wrong here why can I not get any output? Thanks Ben
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
I am a newbie with creating jar files, but I suspect that you need to change the name of mainclass to manifest. I think there is also a way to specify the file to use as the manifest file, but I'm not exactly sure. Alternatively, you can specify a class name to run explicitly when you use the java command. In this case, you could use: java -jar apple.jar Apple
Originally posted by ben riches: Hello All, I have ... a text file called mainclass (which holds this: Main-Class: apple)...
Is that text file named "Manifest.mf" and is it in your jar's "meta-inf" folder?
ben riches
Ranch Hand
Joined: Nov 08, 2002
Posts: 126
posted
0
Originally posted by Billybob Marshall:
Is that text file named "Manifest.mf" and is it in your jar's "meta-inf" folder?
the text file is named mainclass.txt, and where would my jar's meta-inf be? Thanks Ben
Jason Fox
Ranch Hand
Joined: Jan 22, 2004
Posts: 114
posted
0
To add a Manifest file, simply use this syntax: jar cvfm YourJar'sName.jar yourmanifesttextfile -C directorywithyourclassfiles/ if that works for you, use jar -tf YourJar'sName.jar to view the contents of the jar file Jason
ben riches
Ranch Hand
Joined: Nov 08, 2002
Posts: 126
posted
0
Originally posted by Jason Fox: To add a Manifest file, simply use this syntax: jar cvfm YourJar'sName.jar yourmanifesttextfile -C directorywithyourclassfiles/ if that works for you, use jar -tf YourJar'sName.jar to view the contents of the jar file Jason
I done what you said and I keep getting this error: c:\j21work\I>jar cwfm apple.jar mainclass -c:\j21work\I\apple.class java.io.IOException: invalid header field
Thanks Ben
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
Try jar cwfm apple.jar mainclass -c:\j21work\I\
Lalit K Kumar
Ranch Hand
Joined: Jan 29, 2004
Posts: 32
posted
0
hi, Remember the extension of your manifest file must be .tmp and not .txt. manifest.tmp must contain the following text: Name: yourfilename.class Java-Bean: True now run the command jar cfm yourfilename.jar manifest.tmp yourfilename.class give the path of manifest file (instead of manifest.tmp) in case it is not in the same folder as your files are.