开发者

How would I remake a Batch File into a Shell Script

I'm using Sublime Text 2, and I want to be able to compile and run Java Files with one button.

When running Windows, the Batch file Required is:

@ECHO OFF
cd %~dp1
javac %~nx1
java %~n1

I'm wondering what that would look like in a Shell Script, cause I don't know much about Shell Scripts...

I'm using the Open JDK and JRE in case it开发者_运维百科 matters.

Thanks for the help,

Kelan


The bash equivalent to that script would be something like:

#!/bin/bash
cd "$(dirname "$1")"
javac "$(basename "$1")"
java "$(basename "$1" ".${1##*.}")"


A shell script would STILL require running a batch file to start it. For example, you could write a Ant task that could do what you are asking, or perhaps a Beanshell script. But, you still wont be able to avoid making a batch file that launches it. The batch file that you are using now is as close as you'll get to a single click solution. Not even a PowerShell script would give you better convenience.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜