找不到主类,程序会退出 [英] Could not find the main class, program will exit

查看:152
本文介绍了找不到主类,程序会退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

jar cvfm MyJarName.jar manifest.txt *.class

创建了.jar文件。但当我尝试打开它时,我会弹出一个窗口,上面写着

which created the .jar file. But when I attempt to open it, I get a pop-up window that says

Could not find the main class: <ClassName>. Program will exit.

然而,当我使用

java -jar jarName.jar

在命令提示符下,它有效精细。这是怎么回事?我希望能够双击它。

in the command prompt, it works fine. What's the deal? I want to be able to just double-click it.

推荐答案

哈,我发现了问题所在。我使用jdk1.7制作了我的程序,但是我安装了jre6。我去了升级到jre7,现在工作正常:)

Ha, I found what the problem was. I made my program using jdk1.7, but I had jre6 installed. I went and upgraded to jre7, and now it works fine :)

java -jar jarname.jar

行在命令提示符下工作,因为我的java路径被设置为jdk文件夹。

line was working in the command prompt because my java path was set to the jdk folder.

这篇关于找不到主类,程序会退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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