“无法找到主要类别”双击.jar文件时 [英] "Could not find the main class" when double-clicking .jar file

查看:234
本文介绍了“无法找到主要类别”双击.jar文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:我意识到这个问题应该很简单,很多人似乎都经历过这个问题。但是,看起来我的问题可能略微与现有帖子不同。

First: I realize that this issue should be quite simple and lots of people seem to have experienced it. However, it appears my issue may be slightly different from existing posts.

我正在使用NetBeans编译Java应用程序。完成构建后,输出会正确进入dist\文件夹。那里有jar文件。如果我转到命令行,请导航到该文件夹​​,然后调用以下内容:

I'm using NetBeans to compile a Java application. When it's done building, the output goes into the dist\ folder correctly. The jar file is present there. If I go to the command line, navigate to that folder, and call the following:

java -jar Prosperity.jar

java -jar Prosperity.jar

一切正常。显然,应用程序的名称是Prosperity。以下命令也可以正常工作:

everything works fine. Obviously the name of the application is Prosperity. The following command also works fine:

javaw -jar Prosperity.jar

javaw -jar Prosperity.jar

但是,双击。 jar文件给出消息:找不到主类:,然后给出.jar文件的路径。我已经检查过一百次.jar文件中存在META-INF文件夹,并且其中存在一个具有正确主类名的MANIFEST.MF。我还检查了主类(App.class).class文件是否存在于.jar文件中。

However, double-clicking the .jar file gives the message: "Could not find the main class:", and then gives the path to the .jar file. I've checked a hundred times that the META-INF folder exists inside the .jar file, and that within it there exists a MANIFEST.MF with the correct main class name. I have also checked that the main class (App.class) .class file exists inside the .jar file.

所以问题是:双击之间的区别是什么一个文件并运行javaw吗?它真的很令人沮丧,它不会只是运行!

So the question is: what's the difference between double-clicking a file and running javaw on it? It's getting really frustrating that it won't just run!

感谢你能给我的任何方向,我是tearin'我的头发在这里!

Thanks for any direction you can give me, I'm tearin' my hair out here!

推荐答案

也许你的文件关联搞砸了。在命令提示符下,尝试运行

Perhaps your file associations got messed up. At the command prompt, try running

ftype | find "jarfile"

在我的64位Windows 7计算机上,显示

On my 64-bit Windows 7 computer, that shows

jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*

您也可以使用 ftype

ftype jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*

这篇关于“无法找到主要类别”双击.jar文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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