0

i want to execute this shell script:

export.run

cd ./AndroidExport/
ant release

with this java code:

      .....
      Runtime shell = Runtime.getRuntime();
        Process prozess = null;
        String cmd = "sh ./export/android/export.run";
        try {
            prozess = shell.exec(cmd);

        } catch (IOException ioe) {
        }
         BufferedReader in = new BufferedReader(
           new InputStreamReader(prozess.getInputStream()) );
         String line;

   while ((line = in.readLine()) != null) {
     System.out.println(line);
   }
   .....

When i execute the shell script in a console, it compile the android project and i get this output:

Buildfile: /home/myhome/NetBeansProjects/ITGEditor/export/android/AndroidExport   /build.xml

  -set-mode-check:

  -set-release-mode:
   [echo] *************************************************
   [echo] ****  Android Manifest has debuggable=true   ****
   [echo] **** Doing DEBUG packaging with RELEASE keys ****
   [echo] *************************************************

and many more lines, but when i execute it with java, it wan´t compile it and the java console only print the first line:

Buildfile: /home/myhome/NetBeansProjects/ITGEditor/export/android/AndroidExport   /build.xml

Where is the problem? Thanks!

rainer zufall
  • 100
  • 2
  • 7
  • Have a look at [this](http://stackoverflow.com/questions/8149828/read-the-output-from-java-exec) question. Uses `ProcessBuilder` and redirects standard error to standard output, perhaps that help you as well. – Katona Sep 08 '13 at 20:17

1 Answers1

0

Try to add -l option to your shell command:

        String cmd = "sh -l ./export/android/export.run";
konsolebox
  • 72,135
  • 12
  • 99
  • 105