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

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

问题描述

我使用 Eclipse 在 Windows 7 中创建了一个 jar 文件.当我尝试打开 jar 文件时,它说 jar 文件无效或损坏.谁能告诉我为什么 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?

推荐答案

当您在 Windows 资源管理器中双击 JAR 文件时会发生这种情况,但 JAR 本身实际上不是可执行 JAR.一个真正的可执行 JAR 应该至少有一个带有 main() 方法的类,并在 MANIFEST.MF 中引用它.

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.

在 Eclispe 中,您需要将项目导出为 Runnable JAR 文件而不是 JAR 文件,以获得真正的可执行 JAR.

In Eclispe, you need to export the project as Runnable JAR file instead of as JAR file to get a real executable JAR.

或者,如果您的 JAR 只是一堆密切相关的类(一个库)的容器,那么您不应该双击它,而是使用一些 ZIP 工具打开它.Windows 资源管理器默认将 JAR 文件与 java.exe 相关联,这不适用于那些类型的库 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天全站免登陆