Sublime Forum

Sublime user input into console (using scanner class with java and running programs in sublime)


Hi, ive set up sublime so that i can compile and run programs however, when i use the scanner class to allow user input i recieve an error. Is there anyway i can get user input to work with the sublime console?> im using ST2 im sure somehow its possible as notepad++ supports this (sublime is still better).

Thanks in advance




I just posted a better solution @ Post 11

The Original Post is saved for reference.

1 Like

Run Python3 Code with input
Running Python on sublime console

Ah so it launches the console ok cool ty! problem solved!



going one step further is this possible with the portable version of sublime without accessing the c drive?



I’m not completely sure, but I have a few ideas that might work. Post back if any of these work!

###[ 1 ]

If only a filename is given as an argument, "cmd" will check for that file @ PATH variable locations.

You should be able to change it to another drive by using an absolute path.

"cmd": ["D:\runJava.bat", "$file"]

###[ 2 ]

I’m not sure if Sublime Text includes any of its own directories in the PATH search. If it does, you could maybe try relocating the batch file there & leave the sublime-build code as is.

###[ 3 ]

Not sure if this is possible, but:

Include your Java\jdk1.7.0_79 files in the same location as your portable version of Sublime Text.



[1] This also seems like it should work HOWEVER in APPDATA i can access all my packages in sublime which lets u alter the JavaC ect. but in the portable version of sublime this doesn’t exist - there are no packages in the portable version of sublime that can be altered there are only pristine packages which seem like they cannot be altered

No idea? where i would put the batch file - any ideas?

Maybe i will test this on Monday as the computer that im doing this on i wont have access to until then.



Any luck getting this working?



It doesn’t matter anymore. I have it working on normal sublime. Not on portable, that’s good enough (as I won’t be using portable version that much anymore)



I do have another two questions
firstly is there a way so that if and only if the scanner class is imported then it launches the console otherwise it uses the original (runJava.bat).

And can it detect if there is already a console open and use that rather then everytime opening a new one?




Honestly I’m not too sure about either. I haven’t worked with build systems all that much, just enough to get them working.


Maybe look into:
##Build Systems
##Using Batch Files
##Batch Files & Batch Commands
##Using Windows PowerShell



I just created a new script which is a lot more customizable than the one I originally posted.

###Check it out @:
##[TEMPLATE] Powershell Script for Multi-Command Builds with Input