I have these files board.class and x4.class (x4.class has main() method).
To jar these files, I wrote
jar cf x4.jar *.class
and got a x4.jar file.
I copied this x4.jar file to my Desktop (on windows Vista) and double-clicked it. I am getting this error:
Failed to load Main-Class manifest
attribute from
C:\Users\eSKay\Desktop\x4.jar
What should I do to make this file run as a jar executable (without installing any software)?
UPDATE:
I used a manifest file to fix the problem. I have got the jar file I needeed and it is running fine if you do:
java -jar x4.jar
But, when I double click x4.jar nothing happens, I checked Task Manager and found that a javaw.exe is being started in the background, but it is not showing the output the original program was giving.
What can the problem be?
You need to create a manifest file which contains the
Main-Classattribute to specify its entry point. Then use the “m” flag in the jar command to specify it. For example, you might have a file called manifest.txt:Note that you need to have an empty line at the end of the file, or the
jartool won’t process it properly, ignoring the final line silently.Then run:
To test it, run: