2012-12-16 60 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

我試過了,但仍拋出相同的異常! ! –