How to pass argument to java bash script? [duplica

2020-07-27 02:24发布

I have a simple bash script which runs my java program. Here is it:

run.sh

#!/bin/sh
java -jar target/my-jar-arch.jar

I want to pass arguments to this script, which must pass them to java program:

bash run.sh myArg -key 100

When I try to execute this line my app doesn't get any parameters. How can I fix it?

标签: java bash
1条回答
▲ chillily
2楼-- · 2020-07-27 03:05

Change your invocation line to:

java -jar target/my-jar-arch.jar "$@"
查看更多
登录 后发表回答