Results 1 to 3 of 3
  1. #1
    emyk is offline Member
    Join Date
    Mar 2011
    Posts
    19
    Rep Power
    0

    Default Trying to run to JAR files one after the other

    I am trying to call two .JAR files from a JAVA program one after the other.The second Jar file picks up the output from the first JAR file. For some reason It only runs the first call. It seems that the first call does not release the system resource. So how do I force the first call to release the system resource for the second one? Any assistant is greatly appreciated.

    try {

    Process proc = Runtime.getRuntime().exec("java -jar C:\\File1.jar");
    InputStream in = proc.getInputStream();
    InputStream err = proc.getErrorStream();
    System.out.println("Write File OK " );
    in.close();
    err.close();

    } catch ( IOException e) {

    }

    try {

    Process proc = Runtime.getRuntime().exec("java -jar C:\\File2.jar");
    InputStream in = proc.getInputStream();
    InputStream err = proc.getErrorStream();
    System.out.println("Write File OK " );
    in.close();
    err.close();

    } catch ( IOException e) {

    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    Read and implement the recommendations in all the sections of When Runtime.exec() won't.

    Also, since you stated that you need to run the two Java processes in sequence, you'll probably want to introduce a Process#waitFor

    db

  3. #3
    emyk is offline Member
    Join Date
    Mar 2011
    Posts
    19
    Rep Power
    0

Similar Threads

  1. Replies: 8
    Last Post: 07-30-2010, 05:47 PM
  2. import from dsv files and export to csv files
    By 10x2 in forum New To Java
    Replies: 12
    Last Post: 04-30-2010, 11:56 AM
  3. working with files (text files)
    By itaipee in forum New To Java
    Replies: 1
    Last Post: 02-24-2009, 11:38 AM
  4. Behaving text files like binary files
    By Farzaneh in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 03:20 PM
  5. how to convert mpeg files to .wav files
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •