I've created a .jar in which I have a script named init.sh
I got this error.
tim@TS:~/Desktop$ java -jar test.jar java.io.IOException: Cannot run program "/init.sh": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:621)
at java.lang.Runtime.exec(Runtime.java:486)
at Main.run(Main.java:42)
My code which works when I run on Eclipse is below.
String[] cmd = {"src/init.sh"}; try { Runtime.getRuntime().exec(cmd); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
I've tried to change it without success like that.
String[] cmd = {"init.sh"};
I looked at my .jar file and the init.sh script is at the same level as the Main.class.
My question is : How must I change my code if I want to get a functional .jar ?