I would like to create a process in my application. But after looking around and from Java's API I still don't quite get it.
Basically I want to create a multi process application. But the new process is a class in my application.
I know some of you might ask why not create a thread? Because the class is calling a matlab code, the problem and the Java class is Here
Is there any way to do this?
To end a Java program, we can use the exit() method of the System class. It is the most popular way to end a program in Java. System. exit() terminates the Java Virtual Machine(JVM) that exits the current program that we are running.
start() method of ProcessBuilder returns a Process instance. You can call destroy() method on it. destroy() returns error exit value.
waitFor. public abstract int waitFor() throws InterruptedException. Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated.
Process provides control of native processes started by ProcessBuilder. start and Runtime. exec. The class provides methods for performing input from the process, performing output to the process, waiting for the process to complete, checking the exit status of the process, and destroying (killing) the process.
Maybe java.lang.Process could help here ..
The
ProcessBuilder.start()
andRuntime.exec
methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it. The class Process provides methods for performing input from the process, performing output to the process, waiting for the process to complete, checking the exit status of the process, and destroying (killing) the process.
There is only one way to create processes in Java, Runtime.exec()
- basically it allows you to start a new JVM just as you would via the command line interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With