We are using Java 8 and have more that 10 shell scripts. We are calling 10 shell scripts in Java in Spring Boot application using below approach:
Runtime runtime = Runtime.getRuntime(); Process process = Runtime.exec(command); process.waitFor();
ProcessBuilder p = new ProcessBuilder(command); p.start();
It is working fine as expected. But it is consuming server memory and finally it is creating out of memory issue. Even I closed all resource in finally block.
Still I am facing memory issue. Is it the right approach to call shell script in Java?