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
哪个类型是变量'br'? 'strInput'不是一个表示整数的字符串。 – 2013-03-04 22:04:12
@SotiriosDelimanolis嗨,那就在这里 'code // Stream和Buffered读取器接受用户输入 InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); ' 用户需要为该程序的该部分输入一个数字,并设置一个catch(IOException) – 2013-03-04 22:06:29