Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.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 如何通过mvn测试将hibernate3:hbm2ddl编译为Runtime.getRuntime().exec的参数?_Java_Hibernate - Fatal编程技术网

Java 如何通过mvn测试将hibernate3:hbm2ddl编译为Runtime.getRuntime().exec的参数?

Java 如何通过mvn测试将hibernate3:hbm2ddl编译为Runtime.getRuntime().exec的参数?,java,hibernate,Java,Hibernate,我在本地驱动器中有一个文件夹,C:\PK 我想为此文件夹运行hbm2ddl命令。 我用这个来调整我的代码 Process p= Runtime.getRuntime().exec("C:\\PK\\ mvn test-compile hibernate3:hbm2ddl"); 这里我得到了这样的错误 Cannot run program "C:\PK\": CreateProcess error=5, Access is denied 如果我把代码改成这个 Runtime runTime =

我在本地驱动器中有一个文件夹,C:\PK 我想为此文件夹运行hbm2ddl命令。 我用这个来调整我的代码

Process p= Runtime.getRuntime().exec("C:\\PK\\ mvn test-compile hibernate3:hbm2ddl");
这里我得到了这样的错误

Cannot run program "C:\PK\": CreateProcess error=5, Access is denied
如果我把代码改成这个

Runtime runTime = Runtime.getRuntime();
        File f=new File("C:\\PK\\");
        String[] arr=new String[1];
        arr[0]="mvn test-compile hibernate3:hbm2ddl";
        Process p= Runtime.getRuntime().exec(arr,null,f);
然后它会给出以下错误

Cannot run program "mvn test-compile hibernate3:hbm2ddl" (in directory "C:\PK"): CreateProcess error=2, The system cannot find the file specified
谁能解释一下我在这里做了什么错事。?
提前感谢。

这可能是因为您没有将maven\bin文件夹添加到计算机上的环境变量路径中。另外,您在第一次尝试时以错误的方式调用了该命令。请尝试:
“C:\\PK\\mvn test compile hibernate3:hbm2ddl”
,文件夹和命令之间没有空格。我现在已经更新了代码,提供了mvn路径,但仍然给出相同的错误,File f=new File(“C:\\PK”);字符串[]arr=新字符串[1];字符串[]路径=新字符串[1];路径[0]=“C:\\Tools\\apache-maven-3.2.3\\bin”;arr[0]=“mvn测试编译hibernate3:hbm2ddl”;进程p=Runtime.getRuntime().exec(arr,path,f);我也像你说的那样做了,我得到了同样的异常,java.io.IOException:无法运行程序“C:\PK\mvn”:CreateProcess error=2,系统找不到指定的文件