Use the Runtime class to run Cygwin. This is very brittle, and dependent upon your setup, but on my machine I would do:
Runtime r = Runtime.getRuntime();
Process p = r.exec("C:\\dev\\cygwin\\bin\\mintty.exe --exec /cygpath/to/foo.sh");
Then wait for the Process to complete, and get a handle to it's InputStream objects to see what was sent to stdout and stderror.
The first part of the command is to run cygwin, and the second is to execute some script, or command (using -e or --exec). I would test this command on the DOS prompt to see if it works first before cutting any code. Also, take a look at the options available by doing:
C:\dev\cygwin\bin\mintty.exe --help
Also from within the DOS prompt.
EDIT: The following works for me to print version information
public class RuntimeFun {
public static void main(String[] args) throws Exception {
Runtime r = Runtime.getRuntime();
Process p = r.exec("C:\\dev\\cygwin\\bin\\mintty.exe --version");
p.waitFor();
BufferedReader buf = new BufferedReader(
new InputStreamReader(
p.getInputStream()));
String line = buf.readLine();
while (line != null) {
System.out.println(line);
line = buf.readLine();
}
}
}
Unfortunately, can't seem to get it working with --exec, so you're going to have to do some more research there.