Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Terminate JVM created from C++ with CreateProcess

843802Feb 13 2006 — edited Feb 15 2006
Hi!

How can I terminate (from C++) an application running in JVM that I've created with CreateProcess()?

That's the code:

STARTUPINFO startup;
PROCESS_INFORMATION procinfo;

::ZeroMemory(&startup, sizeof(startup));

startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
startup.wShowWindow = SW_HIDE; // hidden console window
startup.hStdInput = NULL; // not used
startup.hStdOutput = NULL;
startup.hStdError = NULL;
BOOL started = ::CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &procinfo);


'cmd' contains, for example, "javaws c:\AMnotepad.jnlp".


If I use TerminateProcess (procinfo.hProcess, 9), this will do nothing, because the HANDLE (and the process ID) it's not the same.


Can somebody tell me why this happens and how can I terminate the process I've created?


Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2006
Added on Feb 13 2006
1 comment
510 views