cornercoder
cornercoder

Reputation: 276

I want to close a windows process started by my java program from java only

I Tried the following code , no exception is raised but the opendhcpserver program does not stop, even tried debugging but still no clue. Using this command to run the program

Process p= new Precess();
p = Runtime.getRuntime().exec("cmd.exe /C C:\\OpenDHCPServer\\OpenDHCPServer.exe -v");

using this to close

p.destroy();

Upvotes: 1

Views: 179

Answers (1)

Vinesh
Vinesh

Reputation: 943

First thing Process is abstract class you cant instantiate it,

Use Separate methods to start & stop an application, so that when you execute start method it will start the application & when you execute stop method it will stop application. Then it will work as you think.

Upvotes: 2

Related Questions