Search code examples
javaprocessjvmexternal-process

How to create a process on node from a JVM which is running other node


I have got an usecase where I have to call python script from Java program. Java process (JVM) will have to launch a process on other system/node (not within the same node). How this can be achieved?


Solution

  • If it is the same machine (jvm and python script), you can leverage ProcessBuilder class itself to execute script directly.

    In case of script residing on another box, you can leverage JSch library which provides you ssh capabilities to launch process on remote machine.