0

I am working on Windows and I have downloaded cygwin. I want to launch the cygwin terminal from a java program but I can't find the command so I can launch the terminal and then write line command into it.

When I go to the cygwin Terminal icon parameters, I can see this :

target: C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

But when I use this to launch the terminal on my program:

ProcessBuilder pb = new ProcessBuilder("C:\\cygwin64\\bin\\mintty.exe", "cd Documents");

I have a shell that opens wit this :

cd Documents: No such file or directory

I think that my problem is that I launch the wrong cygwin terminal but I can't find where is the right Cygwin terminal.

Does anyone knows where is the right cygwin terminal so I can write line commands in my java program and the temrinal will understand them ?

Martin G
  • 17,357
  • 9
  • 82
  • 98
Anatch
  • 443
  • 1
  • 5
  • 20
  • What you are doing - you start program mintty with argument "cd Dcouments" - that's for sure not what you want do do. What you want is to start process for mintty, get standard input and output of this process and then feed this input with commands like "cd Documents" and get output of these commands. There is no need to emulate Terminal - you are in full control of this process. As matter of fact Terminal does the same only it shows output to the window and redirect keyboard stream to the input of the process. – Alex Apr 15 '15 at 13:01
  • Process p = pb.start(); BufferedReader input = getInput(p); BufferedReader error = getError(p); while ((ligne = input.readLine()) != null) { System.out.println(ligne); } while ((ligne = error.readLine()) != null) { System.out.println(ligne); } output.write("ls") p.waitFor(); – Anatch Apr 15 '15 at 13:05
  • Here is similar question with good answer http://stackoverflow.com/questions/5803094/java-process-io – Alex Apr 15 '15 at 13:07

0 Answers0