1

I have jar, which must get 2 parameters from command line, I create the sh script (test.sh):

java -jar target/test-SNAPSHOT.jar $1 $2

If I make the script global, how can I pass the full path to the files in the parameters to the parameters of the jar.

1 Answer 1

2

If i understand you correctly, then you are interested in the absolute paths to your script parameters. So you could use realpath.

Script call:

test.sh $(realpath para1) $(realpath para2)

Or in your script:

java -jar target/test-SNAPSHOT.jar "$(realpath "$1")" "$(realpath "$2")"

Some more alternatives are discussed here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.