损坏的jar文件 [英] Corrupt jar file
问题描述
当您在Windows资源管理器中双击JAR文件时,会发生这种情况,但是JAR本身实际上不是一个可执行文件 JAR。一个真正的可执行JAR应该至少有一个具有 main()
方法的类,并在 MANIFEST.MF
中引用它
在Eclispe中,您需要将项目导出为 Runnable JAR文件,而不是以 JAR文件导出一个真正的可执行JAR。
或者,如果你的JAR只是一堆紧密相关的类(一个库)的容器,那么你不应该双击它,而是使用一些ZIP工具打开它。 Windows资源管理器即默认情况下将JAR文件与 java.exe
相关联,这对于这些库存JAR不起作用。
I have created a jar file in windows 7 using eclipse. When I am trying to open the jar file it says invalid or corrupt jar file. Can anyone suggest me why the jar file is invalid?
This will happen when you doubleclick a JAR file in Windows explorer, but the JAR is by itself actually not an executable JAR. A real executable JAR should have at least a class with a main()
method and have it referenced in MANIFEST.MF
.
In Eclispe, you need to export the project as Runnable JAR file instead of as JAR file to get a real executable JAR.
Or, if your JAR is solely a container of a bunch of closely related classes (a library), then you shouldn't doubleclick it, but open it using some ZIP tool. Windows explorer namely by default associates JAR files with java.exe
, which won't work for those kind of libary JARs.
这篇关于损坏的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!