Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 代码在命令提示符下运行,但不在eclipse中运行_Java_Command Prompt_Bufferedreader_Readline_Runtime.exec - Fatal编程技术网

Java 代码在命令提示符下运行,但不在eclipse中运行

Java 代码在命令提示符下运行,但不在eclipse中运行,java,command-prompt,bufferedreader,readline,runtime.exec,Java,Command Prompt,Bufferedreader,Readline,Runtime.exec,下面给出的代码是我尝试在eclipse中运行的代码,当我尝试通过命令提示符运行命令时,它会将stdInput.readLine()返回为null,但运行成功。我做错了什么 public class Recognize { public String Recog(String name) { try { String command="java -cp .;C:\\mywork\\Speaker\\marf-0.3.0-devel-20070108-fat.jar SpeakerIde

下面给出的代码是我尝试在eclipse中运行的代码,当我尝试通过命令提示符运行命令时,它会将
stdInput.readLine()
返回为null,但运行成功。我做错了什么

public class Recognize {
public String Recog(String name)
{   try {
    String command="java -cp .;C:\\mywork\\Speaker\\marf-0.3.0-devel-20070108-fat.jar SpeakerIdentApp --ident C:\\mywork\\Speaker\\testing-samples\\"+name+".wav";
        Process proc = Runtime.getRuntime().exec(command);
         BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
           BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
       name = "";   
       String s ;
       System.out.println(stdInput.readLine());
       // read the output from the command
      // System.out.println("Here is the standard output of the command:\n");
       while ((s=stdInput.readLine()) != null){
              // System.out.println(s);
               String recog = s;
            //   System.out.println(recog);
               String ex = stdInput.readLine();
            //   System.out.println(ex);
               String sb = stdInput.readLine();
             //  System.out.println(sb);
               if ( recog.equalsIgnoreCase(ex))
               {//System.out.println("ACCESS GRANTED");
                name = recog;
              // System.out.print(recog);
                }
               else if (ex.equalsIgnoreCase(sb))
               {//System.out.println("ACCESS GRANTED");
                name = ex;
               // System.out.println(ex);
                }
               else {//System.out.println("ACCESS DENIED");
                name = "";
       }

这一定是因为eclipse默认路径不是由您设置的,所以请尝试根据您的要求设置eclipse默认路径

尝试在eclipse或我的系统中的类“SpeakerIdentApp”的类路径中指定目录位置或JAR文件名,行java-cp。;C:\\mywork\\Speaker\\m…我试过了,但在command promt中试过没有用,它显示NoclasDefFounf异常您能打印出您在标准错误流中得到的吗?