Java - Process Hangs

Discussion in 'Programming' started by Puneetha K, Nov 25, 2013.

  1. #1
    I am calling a command as below:

    Process proc = Runtime.getRuntime().exec(JavaAppCommand);

    Although it starts the java command of another application after few seconds it hangs. I don't see any error and it stays like this forever! I have set stdErr as well but dont see any errors in display.

    Java experts - Kindly assist,

    Thanks,
    Puneetha
     
    Puneetha K, Nov 25, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    
    try { 
      Process p = Runtime.getRuntime().exec(JavaAppCommand);
      BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line = null;
      while ((line = in.readLine()) != null) {
        System.out.println(line);
      }
    } catch (IOException e) {
        e.printStackTrace();
    }
    
    Code (markup):
    Source
     
    ThePHPMaster, Nov 25, 2013 IP
  3. Puneetha K

    Puneetha K Active Member

    Messages:
    235
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Thanks friend. Really appreciated.
    The code you have mentioned i was already using it.

    I found out by using this helpful tutorial.
     
    Puneetha K, Nov 28, 2013 IP