简体   繁体   English

Sublime Text 2-错误,但在IDE中不存在

[英]Sublime Text 2 - Error but not in IDE

I'm trying to use Sublime text and I have changed my compiling settings to also display the output form the java program. 我正在尝试使用Sublime文本,并且更改了编译设置以也显示Java程序的输出。 However, I can not run it in Sublime Text 2, while IntelliJ displays it fine, as does DrJava and Eclipse. 但是,我无法在Sublime Text 2中运行它,而IntelliJ可以很好地运行它,DrJava和Eclipse也可以。

My error is: 我的错误是:

 -----------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] 

The block of code responsible for this, I'm guessing is: 我猜想对此负责的代码块是:

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);

My JavaC.sublime-build file looks as follows: 我的JavaC.sublime-build文件如下所示:

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

and my runJava.bat file looks as follows: 我的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
)

which is located in my "C:\\Program Files (x86)\\Java\\jdk1.7.0_05\\bin" folder. 该文件位于我的“ C:\\ Program Files(x86)\\ Java \\ jdk1.7.0_05 \\ bin”文件夹中。

Any help would be appreciated! 任何帮助,将不胜感激! The entire program can be seen here: http://pastebin.com/d5QDqMbJ 整个程序可以在这里看到: http : //pastebin.com/d5QDqMbJ

Late response but in case anyone is wondering, sublime hasn't imported the utils that you requested in this case. 响应较晚,但万一有人想知道,在这种情况下,sublime尚未导入您请求的实用程序。 It's problems with the running of the code not of its content. 这是代码运行而不是内容运行的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM