Cynosure.X International LLC

:

Add Comment | Related Links | TrackBack
Related Content

Java Runtime.Exec Can't Find Batch File Unless It Exists In Path

Java Runtime.exec is not the easiest method to use. In fact, it's much harder to use than any exec commands I have ever seen. I don't know if it is the heightened security features or what, but it really doesn't make life easy.

Today, I've been trying to execute a batch file using it by passing the batch file as a command and then setting the batch file's directory as the working directory. But I gget the following error message:

java.io.IOException: Cannot run program "Launcher.bat" (in directory "C:\transfer\briefcase\Cyrah Tasks\Prototype Launcher Task"): CreateProcess error=2, The system cannot find the file specified

The thing is, "Launcher.bat" is really in that directory. On the other hand, if I change "Launcher.bat" to "Prototype.bat", then this IOException doesn't occur.

After banging my head on the table for a long time, I finally figured out that I have a DIFFERENT "Prototype.bat" in the "path" environment variable. Java must have checked the path, found that one, and executed the current one in the working directory. What a strange way Java executes external programs?

Chieh Cheng
Wed, 21 Oct 2009 22:40:52 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 3 - 6?
Click button only once, please!

TrackBack

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

12 Users Online

Hacking Digital Cameras
Fun for Photographers


Amazon Associate

Copyright © 1996 - 2017. All Rights Reserved.