简体   繁体   English

bash脚本运行命令行java程序

[英]bash script to run command-line java program

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 run it just like 是否有一些BASH脚本或我可以用我的程序包装的东西,以允许我运行它就像

program arg1 arg2 arg3

and continue to allow me to have variable arguments. 并继续允许我有变量参数。

I just care about Unix systems. 我只关心Unix系统。

I'm sorry for this simple question: I'm a Java developer, not a BASH scriptor. 对于这个简单的问题我很抱歉:我是Java开发人员,而不是BASH脚本。

Here: 这里:

#!/bin/bash

java program "$@"

Or if you want the bash to exit when java is called, use this: 或者如果你想在调用java时退出bash,请使用:

#!/bin/bash

exec java program "$@"

(This replaces the bash process with the java process instead of waiting until java returns.) (这将使用java进程替换bash进程,而不是等到java返回。)

只需使用别名:

alias program='java program'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM