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.

Kokogino
  • 984
  • 1
  • 5
  • 17
Youlfey
  • 565
  • 1
  • 4
  • 19

1 Answers1

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.

Rene Knop
  • 1,788
  • 3
  • 15
  • 27