Skip to Main Content

Java HotSpot Virtual Machine

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!

How do you prevent MS-DOS window from appearing during Runtime.exec()?

843811Dec 1 2001 — edited Jul 7 2006
The question below was attached to the answer for Question of the Week No. 21. I'm having the same problem. Does anyone know the answer? Put another way does anyone know how javaw does it?

Fri Dec 18 09:59:52 PST 1998
rkarasek
On Windows NT 4.0, how can I prevent CreateProcess()
from creating a cmd.exe window when using javaw and
Runtime.exec()? No such cmd.exe window is created if
instead I run "java" from the command line.

I have a C++ server named "foo", and have created
a Java applcation with Swing GUI named "foo.java".
This GUI captures configuration information and
then uses Runtime.exec() to start the C++ app, with
a socket established between the Java app and C++
app for later communication.

This is all working fine, and the Java application
and GUI working as expected. When I run "java foo"
from either the NT command shell (cmd.exe) or MKS
Korn shell (sh.exe) the Java application/GUI starts,
and when it calls Runtime.exec() my C++ process is
started as what appears to be a child process of the
"java" process, that is, no cmd.exe window is created
during the Runtime.exec("foo.exe") call.

However, when running the same Java application from
a shortcut on the desktop via "javaw", when I invoke
Runtime.exec() a cmd.exe window is created before my
C++ server is started. While things are running
ok and my Java app can still communicate with my
C++ server, is there anyway I can prevent this
cmd.exe window from being created, and instead, have
my C++ server run as a child process of javaw (or
an independent process without a cmd.exe)?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2006
Added on Dec 1 2001
17 comments
925 views