4

Is there a way to make Java spawn a bash script on Windows? I have cygwin installed, and I've associated the .sh file extension with cygwin bash. The following code, which works on Linux, isn't working:

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

2 Answers 2

3

Try adding either bash or start as the first parameter.

Sign up to request clarification or add additional context in comments.

1 Comment

I had to provide the full path to "bash.exe" to get it to work. Well, sort of, it's not working yet, but that's another question.
1

I think you'll have to provide the executable itself in order to do this. The Process.exec method only seems to execute exe files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.