How to run jar files sequentially from a shell script

Kosala Lakshitha :

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.

Elliott Frisch :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=237534&siteId=1