0

i created an executable jar file using the command jar cmf <text-file-points-to-main-class> <archive-name.jar> as a result an executable jar file is produced, but when i attempted to open that executable jar using java -jar file-name.jar the following exception is raised

Exception in thread "main" java.lang.NullPointerException
at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:399)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)

the <text-file-points-to-main-class> actually contains--->Main-Class:hello.java also i tried(hello without .java) i can't point what exactly is the problem ? note that the class file works properly

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165
  • Please post the exact contents of your manifest file. – Jon Skeet Dec 16 '12 at 19:52
  • 2
    There's a lot of posts about this already, did none of them really help? http://stackoverflow.com/questions/7368349/nullpointerexception-when-trying-to-run-jar-file http://stackoverflow.com/questions/8192647/failing-to-execute-the-jar-file-using-java-jar-command http://stackoverflow.com/questions/9287997/exception-in-thread-main-java-lang-nullpointerexception-while-trying-to-the – MrLore Dec 16 '12 at 19:52

1 Answers1

1

Main-Class:hello.java

The Main-Class value should be the fully qualified class name, not the file name, e.g. for

package com.example;

public class hello {

you need Main-Class: com.example.hello

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183