Solved

waitFor() never returns after creation of a process with Runtime.exec

Posted on 2003-12-04
5
330 Views
Last Modified: 2008-03-17
when I create a process with Runtime.exec, waitFor() never
returns

im trying to use cvs to check out a project. im calling the process from java. app is running on Unix - Solaris. if one file is specified for check out - it's fine
if whole project is not
code :
...............................................................................
p =
Runtime.getRuntime().exec("cvs checkout FipWAR")


try {
if (isOSWindows() == false)
p.waitFor();//hangs over here - never returns
} catch (InterruptedException e) {
p.destroy();
}
............................................................

thank you

0
Comment
Question by:gmeltsin
5 Comments
 
LVL 15

Expert Comment

by:Raisor
Comment Utility
Hi,

You may try it this way:


        fname = "cvs checkout FipWAR";
        boolean isOsWindows = Env.isOsWindows();

        try
        {
           if (!isOsWindows)
           {
                Process t = Runtime.getRuntime().exec(fname)
                t.waitFor();
            }
        }
        catch(Exception e){
            System.out.println("Error: " +e);
            return "Error";
        }



Best regards, Raisor
0
 
LVL 15

Accepted Solution

by:
jimmack earned 500 total points
Comment Utility
Just in case it's of any use, here's an article on some of the problems that you get with the exec():

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add mobile access to browser application 3 129
VBA color chart bars 12 65
java continue statement 10 72
array6 challenfge 6 62
This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now