Corrupt jar file

后端 未结 12 1126
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 03:42

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 in

12条回答
  •  天命终不由人
    2020-11-30 04:21

    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.

提交回复
热议问题