问题1:请看下面注释,CMD/C 是啥东西?
public class OSExecute { public static void command(String command){
boolean err = false;
try{
Process process = new ProcessBuilder(command.split(" ")).start();
BufferedReader results = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String s;
while((s = results.readLine()) != null){
System.out.println(s);
}

BufferedReader errors = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
while((s = errors.readLine()) != null){
System.err.println(s);
err = true;
}
}catch(Exception e){
if(!command.startsWith("CMD/C")){  //这里的CMD/C是什么意思,为什么要以这个结尾?
command("CMD/C " + command);
}else{
throw new RuntimeException();
}
}
if(err){
throw new OSExecuteException("Errors executing " + command);
}
}
}问题2:下面两段代码是上面代码的补充,可是 eclipse 里不能正常运行,我只能通过 命令提示符 来验证,不知道为什么 eclipse 不能运行,请教下
public class OSExecuteDemo { public static void main(String[] args){
OSExecute.command("javap OSExecute");
}
}public class OSExecuteException extends RuntimeException{ public OSExecuteException(String why){
super(why);
}
}

解决方案 »

  1.   

    1、以CMD/C开头不是结尾。"CMD/C XXXXXX"表示打开命令行窗口,执行XXXXXX,然后关闭命令行窗口
    2、那就是eclipse的原因了
      

  2.   

    2、详细点:OSExecute.command("javap OSExecute")表示执行 javap OSExecute 命令,javap OSExecute意思是反编译OSExecute,eclipse中源码文件(xx.java文件)和编译后的.class文件不是放在同一个文件夹下面。而如果在命令行中用javac得到的.class文件和其源码文件在同一文件夹下。就是这个原因导致eclipse中不能正确运行。
      

  3.   

    这里的CMD/C是什么意思,为什么要以这个结尾?
    不是结尾是开始