2015-04-02 37 views
-5

我目前正在運行和開發遊戲服務器,但事情是我不能在eclipse上運行它,但我可以運行服務器與run.bat 我「M收到錯誤:異常在線程「主」java.lang.ArrayIndexOutOfBoundsException:3

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 
at com.rs.ServerLauncher.main(ServerLauncher.java:75) 

相關代碼

public static void main(String[] args) throws Exception { 
       if (args.length < 3) { 
         System.out.println("USE: guimode(boolean) debug(boolean) hosted(boolean) port(integer)"); 
         return; 
       } 
       Settings.ECONOMY_MODE = Boolean.parseBoolean(args[2]); 
       Settings.DEBUG = Boolean.parseBoolean(args[1]); 
       Settings.SERVER_PORT = Integer.parseInt(args[3]); 
..... 
..... 
..... 

完整代碼-My ServerLauncher類:http://pastebin.com/k1XZbqva

在此先感謝。

+2

在您的問題中發佈代碼,以便有類似問題的人可以找到此帖子。 – Pshemo 2015-04-02 10:31:45

+0

「你的問題發佈在你的問題」是什麼意思? 我說我不能發佈全班,因爲它不會讓我。 我提供了整個班級的pastebin鏈接 – Mikk 2015-04-02 10:32:32

+0

你應該發佈一個[MCVE](http://stackoverflow.com/help/mcve) – Jens 2015-04-02 10:33:19

回答

1

有你的錯誤,陣列開始與索引0和不與索引1

Settings.ECONOMY_MODE = Boolean.parseBoolean(args[2]); 
Settings.DEBUG = Boolean.parseBoolean(args[1]); 
Settings.SERVER_PORT = Integer.parseInt(args[3]); 
0

這就像誤差表示,args數組不具有四分之一(參數[3])元件。請記住,數組以索引0開頭。

相關問題