开发者

bash script to run command-line java program

开发者 https://www.devze.com 2023-02-26 07:08 出处:网络
Currently I run my program like this: java program arg1 arg2 arg3... There are a variable number or arguments. Is there some BASH script or something I can package with my program to allow me to r开

Currently I run my program like this:

java program arg1 arg2 arg3...

There are a variable number or arguments. Is there some BASH script or something I can package with my program to allow me to r开发者_如何学编程un it just like

program arg1 arg2 arg3

and continue to allow me to have variable arguments.

I just care about Unix systems.

I'm sorry for this simple question: I'm a Java developer, not a BASH scriptor.


Here:

#!/bin/bash

java program "$@"

Or if you want the bash to exit when java is called, use this:

#!/bin/bash

exec java program "$@"

(This replaces the bash process with the java process instead of waiting until java returns.)


Just use an alias:

alias program='java program'
0

精彩评论

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