2

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?

1
  • java -jar target/my-jar-arch.jar "$@" Commented Dec 7, 2014 at 15:29

1 Answer 1

6

Change your invocation line to:

java -jar target/my-jar-arch.jar "$@"
Sign up to request clarification or add additional context in comments.

4 Comments

Oh maybe you know how to make my script executable? If I run it run myArg -p 100 I get -bash: run: command not found. Seams the problem is in my env.
It should be ./run.sh. Unix systems won't automagically "append extensions" or whatever; in fact they don't have the notion of an extension at all.
The problem isn't in extension. It is in my .bash_profile I think.
is there any possibility to pass few bash variables in to the java -jar command? Eg:- java -jar org.sample.jar $HOST $PORT assume I already have HOST and PORT defined within my bash script.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.