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,734
  • 9
  • 41
  • 60
l'arbre
  • 719
  • 2
  • 10
  • 29

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,273
  • 13
  • 26