Если вы посмотрите на содержимое Cygwin.bat
, вы увидите, что он вызывает двоичный файл bash.exe
:
@echo off
C:
chdir C:\cygwin\bin
bash --login -i
Двоичные файлы команд обычно имеют аргумент help
. В этом случае bash наверняка делает:
bash --help
GNU bash, version 3.2.49(23)-release-(i686-pc-cygwin)
Usage: bash [GNU long option] [option] ...
bash [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--protected
--rcfile
--restricted
--verbose
--version
--wordexp
Shell options:
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Type `bash -c "help set"' for more information about shell options.
Type `bash -c help' for more information about shell builtin commands.
Use the `bashbug' command to report bugs.
Теперь, когда мы знаем, какие настройки нужны, ваше Java-приложение может напрямую вызывать bash:
String commandString = "help";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\cygwin\\bin\\bash -c " + commandString);
Не забудьте заменить commandString
значением из вашего компонента Swing.