java - Bash script run jar with external files included does not work -


i have jar file want launch bash script. jar includes references external folder contains images.

when running jar command line absolute path jar, works ok. problem appears when run bash script. apparently folder contains images not found.

launching command line:

java -djava.library.path=/opt/opencv/build/lib -xmx1g -jar /home/version4/podo.jar 

bash script:

#! /bin/bash -x cmd="java -djava.library.path=/opt/opencv/build/lib -xmx1g -jar /home/version4/podo.jar" eval $cmd 

the directory images is: /home/version4/img

the java code accesing images:

 string img_header="./img/header.png";  string img_body="./img/body.png";  bufferedimage header,body;  header=imageio.read(new file(img_header));  body=imageio.read(new file(img_body)); 

the output error:

   javax.imageio.iioexception: can't read input file!     @ javax.imageio.imageio.read(imageio.java:1301) 

can tell me doing wrong? thank you.

you should run bash script same directory run jar file. still, can located in place, meaning detail working directory. better way have store images inside jar, see getting bufferedimage resource work in jar file

in case, should not use absolute paths retrieve images solution destroys portability of jar.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -