This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
its not giving any exception but its not running the .bat file also.
The remote process will not throw exceptions. This is a good article on the common problems using exec(). As Keith points out, you should be reading the output from the process. You should also check the exit code of the process. There are some things that just aren't well-suited for running with exec(). What are you trying to do?
Author and all-around good cowpoke
Joined: Mar 22, 2000
Running .bat files as a Process should be easy if you pay attention to: 1. consuming the standard out stream in a separate Thread 2. consuming the standard err stream in a separate Thread (NOT the thread in 1) 3. constructing the command line properly (so many alternatives!!!) 4. avoiding dependence on the "current" directory
Joined: Aug 29, 2006
if suppose i have a dos command in batch file like one:
then it should have make a new folder on the curret drive! but its not
Originally posted by Joe Ess: This is a good article on the common problems using exec().
More specifically, take a look at "Assuming a command is an executable program" on page 3. It's exactly describing your problem (the problem with bat-files is similar - they aren't programs, either).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Aug 29, 2006
yes , its working fine. now i can run .bat from .java. the thing is that the commands inside the batch file need to mention properly. i was been trying relative path to create the folder in command inside .bat file.
we need to mention Absolute path.
The second thing is that if my application is running on both windows and linux system. now on linux system we have other extension of batch file. how to handle this at a time.