0

I'm running a shell script using:

Runtime.getRuntime().exec(command);

Everything works fine, exept for the output. So, this script

echo "opening gedit..."
gedit

Opens gedit, but when running from Java I don't get any output. What is the problem?

DavidPostill
  • 7,453
  • 9
  • 38
  • 57
l'arbre
  • 707
  • 1
  • 8
  • 27

1 Answers1

0
 String line;
  Process p = Runtime.getRuntime().exec(...);
  BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
  while ((line = input.readLine()) != null) {
    System.out.println(line);
  }
  input.close();

As mentioned in Printing Runtime exec() OutputStream to console

Community
  • 1
  • 1
mulya
  • 1,253
  • 13
  • 24