devxlogo

Process class

Process class

Question:
Using VCafe 2.8 in a Win95 enviornment, I’m trying to spawn a local executable during the runtime of a Java application. I’ve tried using:

Process p = Runtime.getRuntime().exec(strCmd);

but the only value of “strCmd” that was successful was strCmd = "c:command.com /c dir"

I’m really trying to run something like Windows Notepad, or even a *.bat file.

Answer:
The only reason you found you had to usecommand.com to invoke a program is because thecommand you used in your test program is not anactual executable. The dir command is part of the command.com shell and cannot be executed separately. If you change your command string to “C:WINDOWSNOTEPAD.EXE”, you should have no problem launching the program. But when executing shell commands like dir, you must invoke command.com.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist