简体   繁体   English

JVM启动器找不到主类

[英]JVM Launcher cannot find main class

I am using NetBeans to build my executable JAR and haven't messed around with any Ant or project settings (using defaults). 我正在使用NetBeans构建我的可执行JAR,并且没有弄乱任何Ant或项目设置(使用默认设置)。

When I go to Run >> Clean and Build Project , I see NetBeans building my JAR and putting it into my project's dist/ directory without a hitch. 当我转到Run >> Clean and Build Project ,我看到NetBeans正在构建我的JAR并将其毫不费力地放入我项目的dist/目录。

When I double-click that JAR to run it, I get the following error message: 当我双击该JAR来运行它时,出现以下错误消息:

Could not find the main class: com.me.myorg.MainApp. 找不到主类:com.me.myorg.MainApp。 Program will exit. 程序将会退出。

If I open up the JAR in WinRAR and extract the META-INF/MANIFEST.MF file, I see the following attribute defined: 如果我在WinRAR中打开JAR并解压缩META-INF/MANIFEST.MF文件, META-INF/MANIFEST.MF看到定义了以下属性:

Main-Class: com.me.myorg.MainApp 主类:com.me.myorg.MainApp

Obviously, com.me.myorg.MainApp is the "head" of my GUI (Swing) app. 显然, com.me.myorg.MainApp是我的GUI(Swing)应用程序的“头”。

Any ideas as to what is going on? 有什么想法吗? How to troubleshoot? 如何排除故障? Thanks in advance. 提前致谢。

Try in command prompt(Windows): 在命令提示符下尝试(Windows):

ftype jarfile="C:\PATH_TO\javaw.exe" -jar "%1" %

EDIT 编辑
Run the command prompt like this: Go to Start and in the Search box type CMD. 像这样运行命令提示符:转到“开始”,然后在“搜索”框中键入CMD。 Right click the Command Prompt icon and choose Run as Administrator . 右键单击“命令提示符”图标,然后选择“以管理员身份运行”
http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/ http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/

Then run the command above. 然后运行上面的命令。

Is there a new line after the main class declaration? 主类声明后是否有新行?

Main-Class: com.me.myorg.MainApp
# empty line here

The manifest file format requires each line to end with a line separator. 清单文件格式要求每行以行分隔符结尾。 If the line with main class is the last line in the file it is ignored. 如果主类所在的行是文件中的最后一行,则将其忽略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM