java. io. IOException: error = 2, there is no such file or directory

I tried to use runtime getrunTime(). Exec runs a java program from another Java program

code:

String java_home = System.getenv("JAVA_HOME");
 String[] command = {""+java_home+"/bin/java -cp -cp /sc/sug/p-lib/*  Tdesigner -cd /pr -in ing.rsp -out /scratch/sug/ng.pla -ad -stopO "};
                try {
                    proc = Runtime.getRuntime().exec(command);
                    proc.waitFor();
                    int exitCode = proc.exitValue();
                } catch (IOException e) {
                        e.printStackTrace();
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }

It gave me the following errors:

java.io.IOException: Cannot run program "/net/sl/sc/jdk6/bin/java -cp /sc/sug/p-lib/*  Tdesigner -cd /pr -in ing.rsp -out /scratch/sug/ng.pla -ad -stopOnError ": java.io.IOException: error=2,No such file or directory
            at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
            at java.lang.Runtime.exec(Runtime.java:593)
            at java.lang.Runtime.exec(Runtime.java:466)

Anyone can help me solve this problem Yes, I need to use - CP to add a single jar file instead of setting a directory

Solution

Try to remove the extra - CP from the command string array and use a single tag in the array:

String[] command = { java_home + "/bin/java","-cp","/sc/sug/p-lib/*","Tdesigner","-cd","/pr","-in","ing.rsp","-out","/scratch/sug/ng.pla","-ad","-stopO" };
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>