-3

I was wondering if i could start a .sh from a .jar file.

I think i would go something like this:

start "test.sh"

but that did not work.

user2649805
  • 303
  • 1
  • 3
  • 7

1 Answers1

0

Yes, you can. Exemplary code in your jar:

Runtime r = Runtime.getRuntime();
Process p = r.exec("./script.sh");
p.waitFor();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = b.readLine()) != null) 
{
    System.out.println(line);
} 
Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
  • sorry stupid question... also the "How to run Unix shell script from java code? " did not appear in the already answer box – user2649805 Aug 08 '13 at 23:51