- Code: Select all
@ECHO OFF
javac %1.java
if errorlevel 1 goto error
echo [OK, running... ]
java %1
goto end
:error
echo [Compile was unsuccessful]
goto end
:end
@ECHO OFF
javac %1.java
if errorlevel 1 goto error
echo [OK, running... ]
java %1
goto end
:error
echo [Compile was unsuccessful]
goto end
:end$ cat javacr.sh
#!/bin/sh
javac $1.java
java $1C0D312 wrote:Little error in your sh script. you have "javac" twice. The second one should be "java"
should be:
- Code: Select all
$ cat javacr.sh
#!/bin/sh
javac $1.java
java $1
@ECHO OFF
javac %1.java
if errorlevel 1 goto error
echo [OK, running... ]
java %1
goto end
:error
echo [Compile was unsuccessful]
goto end
:endC0D312 wrote:Little error in your sh script. you have "javac" twice. The second one should be "java"
should be:
- Code: Select all
$ cat javacr.sh
#!/bin/sh
javac $1.java
java $1
#!/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
{
"cmd": ["javacrun.sh", "$file_base_name" ],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
"selector": "source.java"
}
lluuuk wrote: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?
#!/bin/bash
CD_CMD="cd "\\\"$(pwd)\\\"" && clear"
VERSION=$(sw_vers -productVersion)
if (( $(expr $VERSION '<' 10.7) )); then
RUNNING=$(osascript<<END
tell application "System Events"
count(processes whose name is "iTerm")
end tell
END
)
else
RUNNING=1
fi
if (( $RUNNING )); then
osascript<<END
tell application "iTerm"
activate
set term to (current terminal)
tell term
set sess to (current session)
tell sess
write text "$CD_CMD"
end tell
end tell
end tell
END
else
osascript<<END
tell application "iTerm"
activate
set sess to the first session of the first terminal
tell sess
write text "$CD_CMD"
end tell
end tell
END
fiUsers browsing this forum: Google [Bot], Majestic-12 [Bot], shengy and 7 guests