-2

Possible Duplicate:
Failing to execute the jar file using java -jar command

I was working on a project in NetBeans and was able to compile without any errors but when I tried to run the sample.jar file by double clicking on it, all I got was an error from the JVM:

A Java Exception has Occurred

So I tried running from command prompt using

prompt>java -jar sample.jar

and I got the following error

Exception in thread "main" java.lang.NullPointerException
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Can anyone help with this?

Community
  • 1
  • 1
Leo Aso
  • 11,898
  • 3
  • 25
  • 46
  • 1
    Moving the answer to the comment: it seems that the answer to your question is available already in Stack Overflow, as pointed out by maksimov. Since you are using Netbeans, it seems that right-clicking on the executable class and choosing the option "define as main class" might solve your problem. – rlinden May 30 '12 at 16:18

1 Answers1

0

You must create a manifest file that indicates the default main class in the jar file, and then add the manifest file to the jar file.

See the documentation on Oracle's jar tool at http://docs.oracle.com/javase/7/docs/technotes/guides/jar/index.html

bithead61
  • 196
  • 1
  • 7