Sublime Forum

Java - Error in Sublime Text 2 but not in IDE

#1

I’m trying to use Sublime text and I have changed my compiling settings to also display the output form the java program. However, I can not run it in Sublime Text 2, while IntelliJ displays it fine, as does DrJava and Eclipse.

My error is:

[code]> -----------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][/code]

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:

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

and my runJava.bat file looks as follows:

@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.

Any help would be appreciated!
The full code can be seen http://pastebin.com/d5QDqMbJ

0 Likes

#2

Are you trying to read from the console input? That’s not possible from within ST2, you’ll have to run your program in a proper terminal.

0 Likes

#3

Any way to launch that from within ST2? It makes things easier.

0 Likes