Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Class - Do not wait for process to exit

Tags:

java

process

I have created a process like so to launch the android emulator:

Process p = Runtime.getRuntime().exec("emulator.exe -avd Testing -no-boot-anim -scale 0.42");

My Java class does what it needs to do but it never ends since that Process has not been destroyed. I just want my Java class to do what it needs to do and exit without waiting for or destroying the started process. I've tried:

System.Exit(0)

But my Java class doesn't get pass it. What can I do?

like image 942
Abs Avatar asked Oct 11 '22 11:10

Abs


1 Answers

You have to processes the child process' stdout (and stderr) otherwise the call to exec method is blocking. See here Why does Process.waitFor() never return?

like image 137
Manuel Selva Avatar answered Oct 13 '22 01:10

Manuel Selva