问题描述
我在Eclipse中制作了一个游戏并打包了所有类 test.jar
中的文件。当我尝试运行它时,它会给我错误:
I made a game in Eclipse and packaged all the class files in test.jar
. When I attempt to run it, it gives me the error:
Error: invalid or corrupted jar file.
我打开 .jar
文件使用Winrar,一切都在那里。
I opened the .jar
file using Winrar, and everything is in there.
我在Stack OverFlow上找了一个类似的问题,但没找到。你能解释一下我如何解决这个错误吗?
I have looked for a similar question on Stack OverFlow, but didn't find any. Can you explain to me how I can solve this error?
对于这个问题的所有人,解决方案:
转到文件,导出,导出为Runnable Jar,选择您的主类,完成。
如果要在cmd中运行程序,请创建一个新的文本文件,然后键入java -jar project.jar,其中包含程序的project = name。
将此保存为Run.bat
然后打开Run.bat,它将自动打开project.jar
多数民众赞成它,它对我有用!
FOR EVERYONE WITH THIS PROBLEM ,SOLUTION:Go to file, export, export as a Runnable Jar, Select your main class, finish.If you want to run your program in cmd, create a new textfile, and type java -jar project.jar with project = name of your program.Save this as Run.batthen open the Run.bat, it will automatically open project.jarThats it, it worked for me!
推荐答案
如何将类放到tar.jar中?有效的jar文件必须遵循它所需的一些规则。您最好通过Eclipse工具生成它们。单击导出 - >jar并选择正确的游戏条目。祝你好运。
How you place your classes to tar.jar? A valid jar file must follow some rules it requires. You'd best generate them by your Eclipse tools. click "export" -> "jar" and select the right entry of your game. Good Luck.
这篇关于使用类创建.JAR文件,错误:文件无效或损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!