How to create bash script from Java on Windows?

Is there a way to make Java spawn a bash script on Windows? I have cygwin installed and I linked the .sh extension to cygwin bash. The following code that works on Linux does not work:

String[] cmdArray = { "scriptName.sh", "-force", categoryName}; Process proc = Runtime.getRuntime().exec(cmdArray, null, directory); 
+4
source share
2 answers

Try adding either bash or starting as the first parameter.

+3
source

I think you will need to provide an executable to do this. The Process.exec method seems to execute exe files.

+1
source

All Articles