2013-03-04 69 views
0

我想使用崇高的文本,我已經改變了我的編譯設置,以顯示輸出形式的Java程序。但是,我無法在Sublime Text 2中運行它,而IntelliJ顯示它很好,DrJava和Eclipse也是如此。崇高的文本2 - 錯誤,但不是在IDE

我的錯誤是:

-----------OUTPUT----------- 
This program will calculate the average for the given number of student's marks 
How many students are in the class? 
Exception in thread "main" java.lang.NumberFormatException: null 
    at java.lang.Integer.parseInt(Unknown Source) 
    at java.lang.Integer.parseInt(Unknown Source) 
    at Unit4ClassAverage.main(Unit4ClassAverage.java:33) 
[Finished in 0.8s with exit code 1] 

負責該代碼塊,我猜是:

System.out.println("This program will calculate the average for the given number of student's marks"); 
      System.out.println("How many students are in the class?"); 
      strInput = br.readLine(); 
      intStudents = Integer.parseInt(strInput); 

我JavaC.sublime-build文件看起來如下:

{ 
    "cmd": ["runJava.bat", "$file"], 
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)", 
    "selector": "source.java" 
} 

我runJava.bat文件看起來如下:

@ECHO OFF 
cd %~dp1 
ECHO Compiling %~nx1....... 
IF EXIST %~n1.class (
DEL %~n1.class 
) 
javac %~nx1 
IF EXIST %~n1.class (
ECHO -----------OUTPUT----------- 
java %~n1 
) 

位於在我的 「C:\ Program Files文件(x86)的\的Java \ jdk1.7.0_05 \ bin」 文件夾。

任何幫助,將不勝感激! 整個程序可以在這裏看到:http://pastebin.com/d5QDqMbJ

+0

哪個類型是變量'br'? 'strInput'不是一個表示整數的字符串。 – 2013-03-04 22:04:12

+0

@SotiriosDelimanolis嗨,那就在這裏 'code // Stream和Buffered讀取器接受用戶輸入 InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); ' 用戶需要爲該程序的該部分輸入一個數字,並設置一個catch(IOException) – 2013-03-04 22:06:29

回答

0

遲到的反應,但如果有人想知道,崇高尚未導入您在這種情況下請求的utils。這是代碼的運行問題,而不是內容的問題。