1

I want to invoke a jar file in my eclipse plug-in application, the code goes like

Process proc;
        try {
            proc = Runtime.getRuntime().exec("java -jar Bunch-3.5.jar");
            proc.waitFor();
            // Then retrive the process output
            InputStream in = proc.getInputStream();
            InputStream err = proc.getErrorStream();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

It can run in a normal java application, but not in the plug-in application. no error and it seems has been executed, but not response

csytang
  • 119
  • 3
  • 10
  • `exec` should work in a plugin but you need to deal with the streams properly before you call `waitFor` see - http://stackoverflow.com/q/8595748/2670892 – greg-449 Sep 27 '16 at 07:17
  • not that problem, I tried but still cannot work – csytang Sep 27 '16 at 09:27

1 Answers1

0

If you run in Linux you need to specify the shell:

proc = Runtime.getRuntime().exec("/bin/sh -c 'java -jar Bunch-3.5.jar'");
Arye Shemesh
  • 582
  • 7
  • 20