java - Unable to call external Bash program when exporting project as runnable jar -
i have java project requires external bash script work. works fine in eclipse, once export runnable jar, following error: cannot run program "src/script.sh": error=2, no such file or directory
i have tried:
runtime.getruntime().exec("script.sh");
as as
new processbuilder("src/script.sh").start();
the bash script takes in no input , not return output
your script buried inside jar file , doesn't exist standalone file, that's why java can't "execute" it. need read @ runtime using resources api, save (temporary?) directory, set executable permission, , run using processbuilder or such.
Comments
Post a Comment