I face a problem to run a ".sh" file from my Java code, which is written in bash. At this point, I am using the following command to run the script (which is in the local directory, and seems to be found):
Process proc1 = Runtime.getRuntime().exec("./"+ nomScript);
proc1.waitFor();
But when executing, I get the error:
CreateProcess error=193, %1 n’est pas une application Win32 valide
(%1 is not a valid Win32 application, the whole error is in the code section below).
java.io.IOException: Cannot run program "./OAD_TCI_20_Blocage.sh": CreateProcess error=193, %1 n’est pas une application Win32 valide
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.coframi.oad.manager.ExecSuperviseur.gererBlocage(ExecSuperviseur.java:406)
at com.coframi.oad.manager.ExecSuperviseur.main(ExecSuperviseur.java:173)
Caused by: java.io.IOException: CreateProcess error=193, %1 n’est pas une application Win32 valide
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 5 more
I tried few things to run the script, as pointing the path to bash.exe as:
Process proc1 = Runtime.getRuntime().exec("pathTobash.exe -c "+ nomScript);
But nothing seems to work.
Does anyone know how I could run this script? Thank you