java.io.IOException:error = 2,没有这样的文件或目录

我试图使用Runtime.getrunTime().exec从另一个 java程序运行 java程序

代码

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();
                }

它给了我以下错误

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)

任何人都可以帮我解决这个问题.是我需要使用-cp添加单个jar文件而不是设置目录.

解决方法

尝试从命令字符串数组中删除额外的-cp并使用数组中的单个标记
String[] command = { java_home + "/bin/java","-cp","/sc/sug/p-lib/*","Tdesigner","-cd","/pr","-in","ing.rsp","-out","/scratch/sug/ng.pla","-ad","-stopO" };

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...