简体   繁体   中英

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).

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.

When I double-click that JAR to run it, I get the following error message:

Could not find the main class: 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:

Main-Class: com.me.myorg.MainApp

Obviously, com.me.myorg.MainApp is the "head" of my GUI (Swing) app.

Any ideas as to what is going on? How to troubleshoot? Thanks in advance.

Try in command prompt(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. 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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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