Question:
Java Executable File Error?
anonymous
2011-07-14 10:11:35 UTC
When I try and run any executable .jar file I always get an error window displaying:
Failed to load Main-Class manifest attribute from [file path here]
I have tried reinstalling Java and JRE and even JDK a number of times but still no fix.
I know this is an error caused normally by bad code concerning the Class but this happens with every file I try to run. I have created a simple Java calculator just to test and ran it successfully in Eclipse but it won't run as an executable .jar file.
What's the problem and how do I fix it?
Thanks
Three answers:
anonymous
2011-07-14 12:01:51 UTC
Some suggestions at:



http://pastebin.com/tRbqv3nM
deonejuan
2011-07-14 12:31:44 UTC
Your .jar will run from command-line with

java -jar Calculator.MainFrame.main();



Eclipse is running the java code with a -cp added, but when you bundle and try to distribute you don't have the MANIF. file with the path set to the class with main()



I use NetBeans and I can open a dialog box to browse to the class with main() and then re-build the .jar



Otherwise, you have to write a text file with the MANIF attributes and use the JDK jar tool with the command-line options to read your text file and write the MANIF. You cannot edit the MANIF directly (otherwise a virus would be trivial).



Some Eclipse users are able to edit the ANT file to make MANIF include the path to main(). I don't know Eclipse but I would think that it has the same feature as NetBeans for packing .jars.
?
2016-10-23 07:26:34 UTC
because of the fact the kit is located in a random folder faraway from the place something of the source is you may desire to characteristic this to the classpath or greater the kit into the comparable itemizing as your contemporary source. the two will artwork


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...