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
what have I done wrong here why can I not get any output?
java -jar apple.jar Apple
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
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
Remember the extension of your manifest file must be .tmp and not .txt.
manifest.tmp must contain the following text:
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.