Results 1 to 2 of 2
  1. #1
    crikey is offline Senior Member
    Join Date
    Jul 2010
    Posts
    125
    Rep Power
    0

    Default Process via ProcessBuilder isn't running

    Java Code:
    @Override
        public void run() {
            File file = new File("./MyJar.jar");
     
            ProcessBuilder pb = null;
     
            try {
                System.out.println(file.getCanonicalPath());
                pb = new ProcessBuilder("java", " -Djava.net.preferIPv4Stack=true -Xbootclasspath/p:" + file.getCanonicalPath()+  "-jar",  file.getCanonicalPath());
                pb.directory(new File("./"));
            } catch (IOException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
            //pb.directory(new File("./"));
     
            BufferedReader stdInput = null;
            try {
                Process proc = pb.start();
                System.out.println("program started started");
     
                proc.waitFor();
            } catch (IOException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            } catch (InterruptedException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
     
     
        }
    When I run this, nothing happens. What could be the problem? I'm trying to run a JAR file with VM parameters

  2. #2
    doWhile is online now Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Process via ProcessBuilder isn't running

    Get the output and error Stream from the process, and read them
    See When Runtime.exec() won't - JavaWorld

Similar Threads

  1. processBuilder
    By Lund01 in forum New To Java
    Replies: 3
    Last Post: 10-11-2011, 01:07 PM
  2. Using ProcessBuilder
    By efebatistaarda in forum Advanced Java
    Replies: 4
    Last Post: 02-11-2011, 08:40 PM
  3. Process running or not
    By smartsubroto in forum New To Java
    Replies: 4
    Last Post: 11-16-2009, 03:09 AM
  4. Controlling the running os process
    By Muralidharan in forum Threads and Synchronization
    Replies: 1
    Last Post: 03-26-2009, 07:03 AM
  5. Process still running
    By gatzke in forum New To Java
    Replies: 12
    Last Post: 01-29-2009, 01:00 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
  •