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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: java program hangs when executed

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java program hangs when executed

    Hi everyone. I m having trouble in a java program. i am trying to execute bash script through a java GUI program in linux. current coding which i am using can actually perform the job but it hangs whenever i press the button. I have to terminate the program through NetBeans IDE stop process. What should I do?

    This is the code which i am using..

    try {
    Process proc = Runtime.getRuntime().exec("/home/user/Desktop/sources_files/script2.sh /");
    BufferedReader read = new BufferedReader(new InputStreamReader(
    proc.getInputStream()));
    try {
    proc.waitFor();
    } catch (InterruptedException e) {
    System.out.println(e.getMessage());
    }
    while (read.ready()) {
    System.out.println(read.readLine());
    }
    } catch (IOException e) {
    System.out.println(e.getMessage());
    }


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: java program hangs when executed

    Hi,

    implement your code according to this article: When Runtime.exec() won't - JavaWorld

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java program hangs when executed

    I tried it. but i do not understand it.i find it difficult a bit.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: java program hangs when executed

    That's not really a question we can reply to. What did you try, specifically? What specifically were you confused about? Where is your updated SSCCE?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. 2nd time not executed while in my program
    By RSelvan in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 26th, 2012, 01:08 PM
  2. Network communication hangs
    By droyhull in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 8th, 2011, 10:55 AM
  3. How to convert java executed pgm in eclipse to excel sheet..
    By rajeshwari in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 17th, 2011, 07:32 AM
  4. Shortcut executed or in-background running Java application
    By xixixao in forum Java Theory & Questions
    Replies: 2
    Last Post: April 22nd, 2011, 04:33 AM
  5. Replies: 3
    Last Post: March 8th, 2011, 07:44 AM