简体   繁体   中英

How to run jar files sequentially from a shell script

I am trying to run two java application one after other in my docker container. In my dockerfile i have specified invoker.sh as the entry point.

ENTRYPOINT ["sh", "/opt/invoker.sh"]

Then i use this script to run two jar files.

#!/bin/sh
java -jar loader.jar
java -jar service.jar

but this does not work. It gives

Error: Unable to access jarfile javaimpl-loader.jar

and only the service.jar is executed. When i tried echo $(ls) it shows that both the jar files are there.

but if i change the script to

#!/bin/sh
echo $(java -jar loader.jar)
java -jar service.jar

then both the jars work. Why cant i use the 1st script. any help regarding this highly apreciated.

It appears the first example is being treated as a single line, you could work with that. Also, I would prefer bash to /bin/sh . Like,

#!/usr/bin/env bash
java -jar loader.jar && java -jar service.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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