损坏的jar文件 [英] Corrupt jar file

查看:177
本文介绍了损坏的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 7中使用eclipse创建了一个jar文件。当我尝试打开jar文件时,它表示无效或损坏的jar文件。任何人都可以建议我为什么jar文件无效?

解决方案

当您在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆