Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a process in Java [closed]

Tags:

java

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?

like image 790
HH. Avatar asked Jan 05 '10 12:01

HH.


People also ask

How do you end a process in Java?

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.

How do I close a process builder?

start() method of ProcessBuilder returns a Process instance. You can call destroy() method on it. destroy() returns error exit value.

What is process waitFor ()?

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.

What is a process in Java?

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.


2 Answers

Maybe java.lang.Process could help here ..

The ProcessBuilder.start() and Runtime.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.

like image 175
miku Avatar answered Oct 19 '22 23:10

miku


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.

like image 32
Michael Borgwardt Avatar answered Oct 20 '22 01:10

Michael Borgwardt