Skip to content
Advertisement

Java Process cannot get the InputStream through Runtime.getRunTime().exec()

JavaScript

The Code has issues with getting the InputStream from the Process, because if I run the Shell script from my Terminal it runs completely fine, but if I Run the Script like this,the str is always null,

I am using this code to get the output of the Shell Script directly into Java instead writing the Script Output in the File

Is there any other way to achieve this,or how can I get the issue solved using the current approach

Advertisement

Answer

I think something returned through the error stream, so you can try to check something from the Process.getErrorStream().

You should also wait for the created process to prevent your main program completes before it. Use Process.waitFor();

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement