Hey guys,
thanks for the tipps…could finally do it =)…I’m on Mac OS X 10.7 running ST2bd2139.
I tried to implement the error handling in the .sh script and I also had to modify it to make it work, don’t know why but the whole $ cat filename thing made it not work and I also had to change the shebang part to /bin/bash instead of /bin/sh…so here’s what I came up with
This is the file javacrun.sh in folder /usr/bin/
#!/bin/bash
echo "Compiling Java sourcecode..."
javac $1.java
if $? == 0 ]; then {
echo "Running the compiled code..."
java $1
} else {
echo "Compiling error, no .class file created"
} fi
for this I created a new build system called JavaCRun.sublime-build with the following code inside:
{
"cmd": "javacrun.sh", "$file_base_name" ],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
"selector": "source.java"
}
it works so far so good, when the code has no errors it makes the desired .class file and runs it. This works good with “Hello World”-type (very simple) programs but it doesn’t really good with programs which require user input (when I run it in Terminal I get prompted to enter something like a number or so, I can’t do this in the sublime text “console”). The code is compiled successfully and the .class file is created but when the script runs the .class file, it doesn’t work good because I can give the needed user input…
is this a limitation from sublimetext console or is there a way to solve this and allow userinput in sublime text?
thanks for your replys!