我正在尝试使用 Sublime 文本,并且我更改了编译设置以显示 java 程序的输出。但是,我不能在 Sublime Text 2 中运行它,而 IntelliJ 可以很好地显示它,DrJava 和 Eclipse 也是如此。
我的错误是:
-----------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