IAmYourFaja
IAmYourFaja

Reputation: 56912

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.

Upvotes: 0

Views: 5148

Answers (2)

Caner
Caner

Reputation: 59198

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.

Upvotes: 1

Joni
Joni

Reputation: 111279

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.

Upvotes: 0

Related Questions