2012-12-16 89 views
0

我使用命令jar cmf <text-file-points-to-main-class> <archive-name.jar>为可执行jar文件产生的结果而创建可执行的JAR文件执行jar文件,但是当我试图打开使用java -jar file-name.jar以下例外是可执行的jar升高不能从CMD

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

<text-file-points-to-main-class>其实包含---> Main-Class:hello.java我也试过了(你好没有.java) 我不能指出究竟是什么问题?注意,类文件正常工作

+0

请发表您的清单文件的确切内容。 –

+2

有很多关于此的帖子,没有人真的帮助过吗? 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-nulpointerexception-while-trying-to-the – MrLore

回答

1

主类:hello.java

Main-Class值应该是完全合格的类名,不是文件名,例如对于

package com.example; 

public class hello { 

你需要Main-Class: com.example.hello

+0

我试过了,但仍抛出相同的异常! ! –