Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Runtime.Exec() not waiting

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts

    Default Runtime.Exec() not waiting

    I am running the command "net use" using Runtime.exec().

    Usually, net use prompts me for a username and password.

    However, when I run the command in java, it prints out the request for username but then it terminates the program without waiting for the user to type in the username and password.

    How do I make my program wait until the user types in the user name and password and how do I make my program receive this input.

    Also... I used p.waitFor() but it really doesn't do much.

    Help much appreciated!

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: Runtime.Exec() not waiting

    Get the input and output Stream's of the process. Here, I'll refer you to the most cited article on the subject: When Runtime.exec() won't - JavaWorld Try those examples with the Input/Ouput streams

Similar Threads

  1. ERROR using Runtime.getRuntime().exec("arp -a");
    By Runomante in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 4th, 2011, 05:09 PM
  2. Waiting for a Second JButton Click
    By Firebert in forum Java Theory & Questions
    Replies: 0
    Last Post: March 16th, 2011, 08:15 PM
  3. Waiting until condition
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 22nd, 2010, 09:24 AM
  4. Runtime.getRuntime().exec(command) - I get nothing
    By andersbk in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 7th, 2010, 08:47 PM
  5. How to Navigate to a URL with Runtime.getRuntime().exec()
    By Flash in forum Java SE API Tutorials
    Replies: 4
    Last Post: October 5th, 2009, 07:18 PM

Tags for this Thread