Using ProcessBuilder

Hi All,
I am using ProcessBuilder in my java code to execute a perl script. The perl script sets up a server using the following code:
$server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1);
die "Can't setup server\n" unless $server;
I get "Cannot setup server" message error message. The perl script runs fine and sets up a server successfully when run from the terminal. However when ProcessBuilder runs this script I get "Cannot setup server" error message. Before running the java code, I assured that the port the perl script uses is not in use.
Is it that I cannot do this with ProcessBuilder?
Can anyone please suggest a remedy/alternative to do this
Thanks,
Akhil

I am posting my reply again in a more readable form.
Here, is my simple Java code that forks a perl script named charniak-parser.pl
public class MyClass {
         public static String runProcess(List<String> command, java.util.Map<String, String> env) throws Exception {
                        ProcessBuilder pb = new ProcessBuilder(command);
                        pb.redirectErrorStream(true);
                        if(env.size() != 0){
                                 java.util.Map<String, String> environment = pb.environment();
                                 environment.putAll(env);
                        Process p = pb.start();
                        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
                        StringBuilder sb= new StringBuilder();
                        String line;
                        while((line = br.readLine())!=null){
                                 sb.append(line '\n');
                        p.waitFor();
                        return sb.toString();
           public static void main(String[] args){
                       java.util.HashMap<String, String> env = new java.util.HashMap<String, String>();
                       env.put("CHARNIAK", "project/akhil/srl/CharniakServer/parser05May26fixed");
                       String message = runProcess(Arrays.asList("nohup", "/project/akhil/srl/CharniakServer/charniak-server.pl", "&>", "charniak-server.log", "&"), env);
                       System.out.println("message: " message);
}In the above code, I have set up an environment variable that is required by the perl script in it's execution.
Here, is the beginning code of my perl script (charniak-parser.pl):
#!/usr/bin/perl
$MAXCHAR = 799;
$MAXWORD = 400;
$charniakDir = "$ENV{CHARNIAK}";
$command = "$charniakDir/PARSE/parseIt $charniakDir/DATA/EN/ -K -l$MAXWORD";
#$endProtocol = "\n\n\n";
$endProtocol = "\n";
$TIMEOUT = 60; # undef if no timeout
$PORT = 4449; # pick something not in use
#read port
$PORT = $ARGV[0] if (scalar(@ARGV) > 0);
use Expect;
#create main program that will be communicating throught pipe.
$main = NewExpect($command);
sub NewExpect {
    my $command = shift;
    my $main;
    print "[Initializing...]\n";
    $main = new Expect();
    $main->raw_pty(1); # no local echo
    $main->log_stdout(0); # no echo
    $main->spawn($command) or die "Cannot start: $command\n";
    $main->send("<s> This is a test . </s>\n"); #send input to main program
   @res = $main->expect(undef,$endProtocol); # read output from main program
    print "[Done initializing.]\n";
    return $main;
#server initialization matter
use IO::Socket;
use Net::hostent; # for OO version of gethostbyaddr
$server = IO::Socket::INET->new( Proto => 'tcp',
                                                    LocalPort => $PORT,
                                                    Listen => SOMAXCONN,
                                                    Reuse => 1);
die "Can't setup server: $! " unless $server;
#end server initializationThe output of the java program is :
[Initializing...]
[Done initializing.]
Can't setup server:Before running the code, I always assure that the port 4449 is free.
If more information required, please let me know.
Akhil

Similar Messages

  • Exception "Cannot run program" while using ProcessBuilder class

    Hi Java-Folks,
    I try to start a program within a Java application using the ProcessBuilder class. This is the first time I use ProcessBuilder so I do not have any deep knowledge of it. Here is a snippet of my code:
    static void connectToHost(String Host) {
    ProcessBuilder pb = new ProcessBuilder("connect.exe"), Host);
    Map<String, String> env = pb.environment();
    env.put("SHELLWIDTH", "64");
    pb.directory(new File("C:\\MyProgram\\ExApp\\shell"));
    try (
    Process p = pb.start();
    } catch (IOException ex) {
    Logger.getLogger(ShellUtil.class.getName()).log(Level.SEVERE, null, ex);
    }Using this method I get an IOException which says *"Cannot run program "connect.exe" (in directory "C:\MyProgram\ExApp\shell"): CreateProcess error=2, The system couldn't find the specified file"*
    Does anybody have an idea why this is not working? I tried to start another application like "notepad.exe" and that works fine. So it seems related to the fact
    that the program I want to start is only available in a certain directory and not via the PATH env-variable.
    I would appreciate any help or hint :-)
    Regards,
    Lemmy

    Okay I guess I misinterpreted the JavaDocs regarding the directory method. The exception message is a little bit confusing too, because it seems like Java tries to find the Application within the specified
    working directory.
    I tried to use the full path with the ProcessBuilder constructor and it looks like this variant is working. I still have some trouble with the application itself but I was able to start another program which is
    not in the PATH var, using the full path to the executable.
    Thanks for the help so far.
    Bye
    Lemmy

  • Use ProcessBuilder to execute a java program with a file piped as input

    Hi,
    I am trying to execute a java program passing in input file as argument. I have to do this by forking a process and am using Processbuilder.
    I have a main function which calls the executeCliTopologyDesigner method. I get a Java I/O exception
    Caught IOException: Cannot run program "$JAVA_HOME/bin/java oracle.apps.fnd.provisioning.cli.TopologyDesigner ": java.io.IOException: error=2, No such file or directory
    Can you please let me know if I am missing something?
    Thanks,
    pkrish
    Code Snippet:
    private synchronized void executeCliToplogyDesigner(String cliCommand, File tmp)
    throws IOException, InterruptedException
    {    File temp= writeDataInTemp(compDefName);
    cliCommand = "$JAVA_HOME/bin/java oracle.apps.fnd.provisioning.cli.TopologyDesigner ";
    ProcessBuilder pb = new ProcessBuilder(cliCommand,"<",temp.getCanonicalPath());
    executeProcess(pb);
    Edited by: pkrish on Mar 2, 2009 3:56 PM
    Edited by: pkrish on Mar 2, 2009 3:57 PM
    Edited by: pkrish on Mar 2, 2009 3:58 PM
    Edited by: pkrish on Mar 2, 2009 3:59 PM

    Hi,
    I printed out the system environment variables PATH and CLASSPATH and it is as below:
    Classpath :/ade/prprasa_prov_latest/fmwtest/tools/orajtst/home/lib/orajtst.jar:/ade/prprasa_prov_latest/jdev/src/abbot/dist/EXTENSIONS
    Path :/ade/prprasa_prov_latest/fxtn/util/tools/ant/bin:/ade/prprasa_prov_latest/fmwtest/tools/orajtst/home/bin:/ade/prprasa_prov_latest/oracle/jdeveloper/jdev/bin:/ade/prprasa_prov_latest/javahome/jdk/bin:/usr/kerberos/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/ade/bin:/OracleProd/oracle10g/bin:/OracleProd/oracle10g/bin:/OracleProd/oracle10g/bin
    The Path does contain java.
    I changed my command as I need a different classpath.
    cliCommand = "/ade/prprasa_prov_latest/javahome/jdk/bin/java -classpath .:/ade/prprasa_prov_latest/oracle/provisioning/tools/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/configframework/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/framework/lib/*"
    Caught IOException: Cannot run program "/ade/prprasa_prov_latest/javahome/jdk/bin/java -classpath .:/ade/prprasa_prov_latest/oracle/provisioning/tools/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/configframework/lib/*:/ade/prprasa_prov_latest/oracle/provisioning/framework/lib/*": java.io.IOException: error=2, No such file or directory
    Any ideas? Please let me know where do I post it if not here.

  • Unable to use ProcessBuilder on Vista, Works on Linux, XP, etc

    Hello, I support an application on many different platforms, and I am running into a problem with Vista. The code works on every combination I have tested (Mac, Linux, various flavors of Windows) except MS Vista and IE7. It even works on both WinXP and IE7 and MS VIsta and Firefox. Unfortunately this is old code and I didn't write it so I'm not sure what to do. It was using RunTime.exec() and I updated it to ProcessBuilder.start() but it has the same symptoms. The symptoms are that instead of the input and output being redirected, a console window is launched and used instead.
    String command = slaunch + " " + appName + " " + app + " " + _debug;
    Process p = new ProcessBuilder(command.split(" ")).start();
    BufferedInputStream stdout = new BufferedInputStream(p.getInputStream());
    BufferedInputStream stderr = new BufferedInputStream(p.getErrorStream());
    boolean keeprunning = true;
    String out = "";
    String err = "";
    int exitvalue = 0;
    while(keeprunning) {
    try {
    exitvalue = p.exitValue();
    keeprunning = false;
    Thread.sleep(300);
    } catch(IllegalThreadStateException itse) {}
    try { Thread.sleep(100); } catch(Exception e) {}
    int available = stdout.available();
    if(available > 0) {
    byte[] buf = new byte[available];
    stdout.read(buf);
    out = out + new String(buf);
    Any help would be greatly appreciated. I am very tempted to tell my Vista users to just use Firefox, but that would go over like a lead balloon.
    James

    Also, your current code is weird. See below.
    public class Bear{
      public void method(){
        String command = slaunch + " " + _appName + " " + _app + " " + _debug;
        Process p = new ProcessBuilder(command.split(" ")).start();
        BufferedInputStream stdout = new BufferedInputStream(p.getInputStream());
        BufferedInputStream stderr = new BufferedInputStream(p.getErrorStream());
        boolean keeprunning = true;
        String out = "";
        String err = "";
        int exitvalue = 0;
        while (keeprunning) { // ????? what's the sense of it?
          try {
            exitvalue = p.exitValue(); // use waitFor() instead
            keeprunning = false; // ?????
            Thread.sleep(300); // ?????
          catch (IllegalThreadStateException itse) {
          try {
            Thread.sleep(100); // ?????
          catch(Exception e) {
          int available = stdout.available(); // never use available()
          if(available > 0) { // ????? no use
            byte[] buf = new byte[available];
            stdout.read(buf);
            out = out + new String(buf);
    //--- a standard code ----
          String line;
          try {
            BufferedReader br
             = new BufferedReader(new InputStreamReader(p.getInputStream()));
            exitvalue = p.waitFor();
            while ((line = br.readLine()) != null){
              out += line;
          catch(Exception e) {
            e.printStackTrace();
    //-------------------------

  • Using ProcessBuilder to execute multiple commands.

    I am having issues getting ProcessBuilder to execute multiple commands in windows.
    As an example I would like to execute "dir /w" fallowed by "java.exe some.App arg1 arg2".
    I can accomplish this from the command line by using "&".
    Example: dir /w & java.exe some.App arg1 arg2 Or: dir /w & dir /c"
    For internal commands (i.e. dir and cd) I know that commands in the array being passed to ProcessBuilder must be formatted like {"dir /w", "dir /c"}
    see post: [http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html]
    Here is an example of one of the many things I have tried:
    {code}
    String[] commands = new String[]{"dir /w", "&", "java.exe", "some.App", "arg1", "arg2"};
    ProcessBuilder pb = new ProcessBuilder(commands);
    pb.start();
    {code}
    Any other ideas / what am I doing wrong?
    Edited by: brianjbrady on May 7, 2009 4:49 PM
    Edited by: brianjbrady on May 7, 2009 4:50 PM

    brianjbrady wrote:
    You can run dir all day long without using cmd.exe. Try it. It works for me.Perhaps you have cygwin in your path.
    How are you running dir out of interest (and don't say with a DOS window ;)
    import java.io.*;
    import java.util.Arrays;
    public class Main {
        public static void main(String... args) throws IOException {
            run("dir");
            run("dir.exe");
            run("cmd", "/c", "dir");
            run("c:\\cygwin\\bin\\dir");
        private static void run(String... command) throws IOException {
            try {
                ProcessBuilder pb = new ProcessBuilder(command);
                pb.redirectErrorStream(true);
                Process p = pb.start();
                InputStream is = p.getInputStream();
                System.out.println("\nCommand " + Arrays.asList(command) + " reported");
                int b;
                while ((b = is.read()) >= 0)
                    System.out.write(b);
                is.close();
                p.destroy();
            } catch (IOException e) {
                System.err.println("\nCommand " + Arrays.asList(command) + " reported " + e);
    }Prints
    Command [dir] reported java.io.IOException: Cannot run program "dir": CreateProcess error=2, The system cannot find the file specified
    Command [dir.exe] reported java.io.IOException: Cannot run program "dir.exe": CreateProcess error=2, The system cannot find the file specified
    Command [cmd, /c, dir] reported
    Volume in drive D is Work Disk
    Volume Serial Number is AC0B-0757
    Directory of D:\dev\scratch
    26/12/2008  22:15    <DIR>          .
    26/12/2008  22:15    <DIR>          ..
    03/09/2007  21:45    <DIR>          classes
    26/08/2008  20:14            65,280 mynamedpipe
    23/11/2008  11:37           201,354 name.ppt.txt
    24/10/2008  20:00           201,354 race.txt
    05/11/2008  23:17         6,193,334 record.csv
    08/01/2009  16:44               704 scratch.iml
    27/12/2008  12:29            21,576 scratch.ipr
    08/05/2009  20:02            53,258 scratch.iws
    28/04/2009  21:34    <DIR>          src
    07/12/2008  11:44               101 test.txt
                   8 File(s)      6,736,961 bytes
                   4 Dir(s)  32,506,023,936 bytes free
    Command [c:\cygwin\bin\dir] reported
    classes      name.ppt.txt  record.csv     scratch.ipr  src
    mynamedpipe  race.txt        scratch.iml     scratch.iws  test.txt

  • Want my client to shutdown the PC using processbuilder!

    Hey All
    I'm working on a Java server and client. Right now i can send my Client strings using sockets and stream readers and writers. Once the Client recieves this string I place it in a processbuilder function and have it execute the "command" it haas been given, a simple example would be the server sending the client the string "calc" and the client executing "calc" to open the calculator.
    My problem is when i send the client a String such as "shutdown -r" to shutdown and restart the client, my client throws an IOException.
    Does anyone have any ideas how I can implement a hardware shutdown, do I need to grant the client special permissions to implment critical commands?
    Thanks in advance
    rev

    http://www.google.com/search?q=shutdown+windows+from+java

  • Cygwin bash using ProcessBuilder

    Hi,
    i am trying to execute a command in a cygwin-bash.
    the java code is:
    import java.io.*;
    public class cmd {
         public static void execute(String cmd_array[]) {
              execute(cmd_array, null);
         public static void execute(String cmd_array[], String work_directory) {
              try {
                   ProcessBuilder pb = new ProcessBuilder(cmd_array);
                   if(work_directory != null) {
                        pb.directory(new File(work_directory));
                   Process process = pb.start();
                   String line;
                   System.out.println("Here is the standard output of the command:\n");
                   BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
                   while ((line = stdInput.readLine()) != null) {
                        System.out.println(line);
                   System.out.println("Here is the error output of the command:\n");
                   BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                   while ((line = stdError.readLine()) != null) {
                        System.out.println(line);
                   process.waitFor();
                   System.out.println(process.exitValue());
              } catch(IOException e) {
                   e.printStackTrace();
              } catch(InterruptedException e) {
                   e.printStackTrace();
    }the following is working:
    String[] cmd_array = new String[2];
    cmd_array[0] = "C:/Program Files/System/Cygwin/bin/bash.exe";
    cmd_array[1] = "--version";
    cmd.execute(cmd_array,"C:/Program Files/System/Cygwin/bin");this does not work:
    String[] cmd_array = new String[3];
    cmd_array[0] = "C:/Program Files/System/Cygwin/bin/bash.exe";
    cmd_array[2] = "--login";
    cmd_array[2] = "-c 'ls'";
    cmd.execute(cmd_array,"C:/Program Files/System/Cygwin/bin");i get the following output:
    Here is the standard output of the command:
    Here is the error output of the command:
    /usr/bin/bash: - : invalid option
    Usage:  /usr/bin/bash [GNU long option] [option] ...
            /usr/bin/bash [GNU long option] [option] script-file ...
    GNU long options:
            --debug
            --debugger
            --dump-po-strings
            --dump-strings
            --help
            --init-file
            --login
            --noediting
            --noprofile
            --norc
            --posix
            --protected
            --rcfile
            --restricted
            --verbose
            --version
            --wordexp
    Shell options:
            -irsD or -c command or -O shopt_option          (invocation only)
            -abefhkmnptuvxBCHP or -o optionIt seems as if the argument --login is not passed correctly.
    Thanks for any help.
    Robert

    Hi,
    i am trying to execute a command in a cygwin-bash.
    the java code is:
    import java.io.*;
    public class cmd {
         public static void execute(String cmd_array[]) {
              execute(cmd_array, null);
         public static void execute(String cmd_array[], String work_directory) {
              try {
                   ProcessBuilder pb = new ProcessBuilder(cmd_array);
                   if(work_directory != null) {
                        pb.directory(new File(work_directory));
                   Process process = pb.start();
                   String line;
                   System.out.println("Here is the standard output of the command:\n");
                   BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
                   while ((line = stdInput.readLine()) != null) {
                        System.out.println(line);
                   System.out.println("Here is the error output of the command:\n");
                   BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                   while ((line = stdError.readLine()) != null) {
                        System.out.println(line);
                   process.waitFor();
                   System.out.println(process.exitValue());
              } catch(IOException e) {
                   e.printStackTrace();
              } catch(InterruptedException e) {
                   e.printStackTrace();
    }the following is working:
    String[] cmd_array = new String[2];
    cmd_array[0] = "C:/Program Files/System/Cygwin/bin/bash.exe";
    cmd_array[1] = "--version";
    cmd.execute(cmd_array,"C:/Program Files/System/Cygwin/bin");this does not work:
    String[] cmd_array = new String[3];
    cmd_array[0] = "C:/Program Files/System/Cygwin/bin/bash.exe";
    cmd_array[2] = "--login";
    cmd_array[2] = "-c 'ls'";
    cmd.execute(cmd_array,"C:/Program Files/System/Cygwin/bin");i get the following output:
    Here is the standard output of the command:
    Here is the error output of the command:
    /usr/bin/bash: - : invalid option
    Usage:  /usr/bin/bash [GNU long option] [option] ...
            /usr/bin/bash [GNU long option] [option] script-file ...
    GNU long options:
            --debug
            --debugger
            --dump-po-strings
            --dump-strings
            --help
            --init-file
            --login
            --noediting
            --noprofile
            --norc
            --posix
            --protected
            --rcfile
            --restricted
            --verbose
            --version
            --wordexp
    Shell options:
            -irsD or -c command or -O shopt_option          (invocation only)
            -abefhkmnptuvxBCHP or -o optionIt seems as if the argument --login is not passed correctly.
    Thanks for any help.
    Robert

  • How to control (the input and output) EXE file after I call it using exec?

    Hi,
    I knew that I can use runtime.exec() to call one EXE file, and this works. But this EXE has two characteristics:
    1. After this exe starts, it asks user to input number such as 1 or 2 onto computer screen, then press return. Then the exe will start the calculation.
    2. after it starts calculation, it prints 3 columns of numbers onto the screen.
    My two questions are:
    1. How to use java to input the number such as 1 or 2 automatically? this EXE can not work like this in DOS command line:
    C:> file.exe parameter
    The parameter is the number such as 1 or 2 that I wanna input.
    2. how to redirect the 3 columns of numbers from computer screen to txt file?
    My colleague can solve these two questions using Mathematica. So I know that definitely there is at least one solution for it. I just can not do it using Java. This wierd exe file bothered me a lot and I really wish that I can get help from someone in java community.
    Thank you!
    Tony

    When you call Runtime.exec, you get a Process object. (I presume something similar happens when you use ProcessBuilder.) Process has methods with names getOutput, getInput, and getError. These correspond to the standard input, standard output, and standard error streams of the spawned process.
    You can read and write to the process on the streams corresponding to input and output that the process writes to the console.
    [add]
    In fact, you should be grabbing and reading the output/error streams anyway, because of the points raised by the Traps article. Google "Java Runtime exec traps" and you'll probably get a link to this JavaWorld article, which describes common Runtime.exec problems and how to solve them.
    Edited by: paulcw on Jun 15, 2010 4:09 PM

  • Using Runtime.exec() to export variables

    I'm developing some code on an AIX machine using ksh (korn shell)
    I need to export a list of variables and then execute a program.
    As far as I can tell, each exec call is a seperate process. So it starts a new shell, runs the command, then exits the shell. I believe that the variables I am attempting to export aren't being saved.
    I've used the following commands:
         export[0] = "sh";
         export[1] = "-c";
         export[2] = "export";
         env[0] = "SYSTEM_VAR=/usr/bin/dir/example";
    sysCall.sysEnvCall(export,env);
    public int sysEnvCall(String[] sysCommand, String[] sysEnv){
         try{
              proc = rt.exec(sysCommand, sysEnv);
              proc.waitFor();
    errorHandler = new SystemStreamHandler(proc.getErrorStream(), "ERROR");           
    outputHandler = new SystemStreamHandler(proc.getInputStream(), "OUTPUT");
         errorHandler.start();
         outputHandler.start();
         exitVal = proc.waitFor();
         if(exitVal > 0)
                   System.out.println("ExitValue: " + exitVal);
         return 0;
              catch(Throwable t)
                   t.printStackTrace();
                   return 1;
              }Please forgive the formatting, it didn't copy/paste well.
    I've tried numerous other export command formats, none of which have worked. If I do an export command followed by either a echo $NEWVAR, or printenv NEWVAR, they are blank.
    I also tried the processBuilder object to no avail. Apparently my system doesn't allow me to "put"/edit system variables.
    If at all possible I would like to run concurrent commands without starting a new shell everytime.
    If anyone has any ideas/suggestions I would greatly appreciate it.
    Thanks much
    Paul

    Once you start a Process, environment variables set in that process will NOT affect the parent process.
    That is a fundamental design choice in UNIX, and you cannot do anything about that.
    Instead, if you just want to set a complicated set of environment variables
    for a new subprocess, you can use ProcessBuilder to do that.
    I also tried the processBuilder object to no avail.
    Apparently my system doesn't allow me to "put"/edit
    system variables.I doubt that. Please post the code for how you tried that.

  • ProcessBuilder Shell Command Output

    When using ProcessBuilder to execute a shell command, certain output seems to be suppressed, for instance:
    ProcessBuilder pb = new ProcessBuilder("ls", "*.java");
    Process ps = pb.start();
    Scanner in = new Scanner(ps.getInputStream());
    while(in.hasNextLine())
              System.out.println(in.nextLine()); // produces no outputFor some reason, this produces no output, even if there are java files in the current directory. If I remove the argument "*.java", then I will get output such as:
    Main.java
    Main.class
    Other.java
    Other.class
    Any idea why I don't get output from filtering my list?

    However, executing sh -c ls *.java doesn't actually filter the listingsThat's not correct.
    so everything is outputted whether it matches the pattern or not.Nor that.
    I suppose I can handle the it though, somehow else.It should work as expected. If it doesn't you have done it wrong.

  • Correct format of arguments to ProcessBuilder

    I am having trouble formatting the arguments correctly to launch a windows application using ProcessBuilder. I created a 'shortcut' in windowsXP with the following parameters:
    TARGET:"C:\Program Files\VirtualDubMod\VirtualDubMod.exe"  /s"R:\Barr0001\03.  AVI Synth Files\TestVinx.vcf" /x
    START_IN:"C:\Program Files\VirtualDubMod"To launch the program from Java, I created the code:
    //init section of the program
    String virtualDubModPath;
    virtualDubModPath="C:\\Program Files\\VirtualDubMod\\VirtualDubMod.exe";
    vDMScr="R:\\Barr0001\\03.  AVI Synth Files\\TestVinx.vcf"
    // Setting up the variables to call a windows program from within Java
              String programString = "\"";
              programString +=virtualDubModPath;
              programString +="\"";
              String arguments1 = "/s";
              String arguments2 = "\""+vDMScr+"\"";
              String arguments3 = "/x";
              ProcessBuilder shell = new ProcessBuilder();
              String [] commands = {arguments1,arguments2,arguments3};
              shell.command(commands);
              shell.directory(new File(virtualDubModPath).getParentFile());
              try {
                   //Process nero = Runtime.getRuntime().exec(commands);
                   Process vDM = shell.start();
    .When the program runs, the error code that is returned from virtualDubMod is "Script File not found". I must be passing the arguments incorrectly.
    I have tried:
    1) Combining arguments 1& 2 (the /s"Filepath")
    2) Removing quote around "Filepath"
    3) Adding double quotes around the ""Filepath""
    4) Replacing the \ path separators in "Filepath" with /
    5) Replacing the \ path separators in Filepath with \\
    6) Adding space between the /s and "filepath"
    7) Eliminating space between the /s and "filepath
    8) Combining the arguments into the programString
    Help would be greatly appreciated

    Print your "commands" array contents to the screen and then you can compare it to the shortcut's target command string - assuming that the shortcut works. See the Arrays.toString(Object obj) method.

  • Create another JVM into JWS and using classpath

    Hello,
    I use Java Web Start to deploy my application, it works. Then into JWS I need to create another JVM using ProcessBuilder with the command java -cp jarNeeded.jar. But I can't use the current jar (in the cache) to set the classpath. How to retrieve this reference to the jar for the classpath of the other JVM?

    Start by ripping your CDs to iTunes in your desired lossless format.
    Download "Convert and Export" from Doug's Applescripts: http://dougscripts.com/itunes/scripts/ss.php?sp=convertandexport
    Create a new folder on your desktop for your converted files.
    Select the files you want converted and run "Convert and Export".
    Create an alternate iTunes library: http://support.apple.com/kb/HT1589
    Be sure to give it a unique name.
    Use the iTunes File menu -> Add to Library and select the folder of converted files.
    After the import is complete, you can delete the folder of converted files from your desktop.
    You can switch between your libraries by holding the option key when starting iTunes.

  • ProcessBuilder - no response - JAVA_HOME - different JREs

    Hello All,
    An application uses ProcessBuilder to execute system commands.
    Locally is working fine with JRE 1.6.
    But it must be runned on a remote machine(no rights to change any settings), which has the JAVA_HOME pointing to a JRE 1.4 instalation folder (if this is relevant).
    Running the application on this machine it stops when trying to run the system command with ProcessBuilder (Note: The application works only with java 1.6).
    Any ideea what can be the problem?
    Many Thanks,
    Bogdan

    I didn't think ProcessBuilder was available in 1.4. You will have to use Runtime.exec().
    P.S. There are many other things that can go wrong with ProcessBuilder/Rutime.exec() unless you implement the recommendations in the four sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • nativelib .exe and the new ProcessBuilder

    Hello all,
    I have a java application that is launched via Web Start.
    In the JNLP file I have:
    <security>
         <all-permissions />
    </security>
    <resources os="Windows">
    <nativelib href="lib/win32/my.jar"/>
    </resources>
    In the root of my.jar are: needed.exe, input.xml, and output.dat
    I am trying to get needed.exe using.
    URL exec = getClass().getClassLoader().getResource("needed.exe");
    But I can't get it to work.
    I've read that: Runtime.getRuntime().exec("needed.exe"); should work, but I couldn't get it to work either (besides I need to use ProcessBuilder.)
    Does anybody have any ideas? What am I overlooking?
    Thanks.

    Interesting, this is a problem.
    findLibrary is protected in ClassLoader.java, but
    public in JNLPClassLoader.java ?
    so ..
    you would have to include javaws.jar in you
    compilation, and :
    String libPath = null;
    ClassLoader loader =
    this.getClass().getClassLoader();
    if (loader.instanceof(com.sun.jnlp.JNLPClassLoader))
    libPath = ((com.sun.jnlp.JNLPClassLoader)
    der) loader).findLibrary(...);
    will this give you "AccessClassInPackageException" ?
    /AndyAndy,
    I had to set things up one way for JNLPClassLoader, and another for running through Eclipse, but that worked.
    I gave you the Duke Dollars if that means anything to you.
    Thank you.

  • ProcessBuilder removes slash

    When I try to open a web page on a browser using ProcessBuilder, it seems trying to remove any more adjacent slashes. Such as
    ProcessBuilder pb = new ProcessBuilder("browser-command \"http://www.google.com\"");The slash behind "http:" is always one on the browser address bar no matter how many I add them, which causes failure to access the page. Any idea?

    You don't need the quotes or the slashes that escape them for that URL.
    In general you're better off using ProcessBuilder(List<String> args) or ProcessBuilder(String[] args), rather than trying to make up the entire command line yourself, which always leads to an escaping-fight with ProcessBuilder, the shell, ...

Maybe you are looking for

  • How can I convert a PSE 8 catalog to a PSE 10 catalog? I have tried numerous times over 3 days.

    I have repaired the PSE * catalog even though no errors were found. There are no *.avi files in the catalog. The conversion has a slight hang up at 34% and again at 82%, continues to the end and reports that the conversion failed. Why do I and so man

  • I cant get live update to work

    I have service pack 2 installed and I cant get on live update because it just dosent load any options at the side bar.  What do I do? Thanks for any help

  • Safari Spinning Out of Control - Why Doesn't This Get Better?!!

    For a very extended period, Safari has been spinnin out of control memory-wise - no other OS I use does this, not does any other browser I use on OSX.  This goes on and on and on and on, with no real remidiation coming from Apple.  It is maddening an

  • Benefit Confirmation Form

    Hello Expert, Would you please tell how to check which benefit enrollment confirmation form is called from the ESS side. We see the differences in the result when called from SAP and when called from ESS. Also could the ESS transaction be called from

  • Serialize ---- Proxy to Idoc scenario

    Hi Folks,             I m using Proxy to Idoc scenario and am trigerring proxy messages one after other from my function module on the outbound side. However sometimes idoc2 gets posted before idoc1. My requirement is that idoc2 to be processed only