A
A
Artur Smirnov2013-07-01 07:19:28
Java
Artur Smirnov, 2013-07-01 07:19:28

Running a third party app?

It is necessary to launch a third-party application from a Java program WITHOUT waiting for the running application to close.
For example:
launched jar'nick — notepad opened (windows environment) and jar's work was completed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Lopatin, 2013-07-01
@wisd

Get familiar with your program. Why is she waiting for something? Does she call Process.waitFor()? Because otherwise the calling program does not wait for the called one to complete. Here is an example code:

import java.io.IOException;

public class Run {
        public static void main(String[] args) {
                try {
                        new ProcessBuilder("/usr/bin/kwrite").start();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }
}

Starts a program and exits (in Linux). Substitute notepad launch and check. Won't a Java program exit?

A
Artur Smirnov, 2013-07-01
@wisd

I need to run a program from Java and close Java application. In this case, the running program will continue to work.
I can only run the application and I can't shut down the Java application. Those. it waits for the application it launched to terminate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question