Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.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 使用Ant&;Eclipse,结果不一样_Java_Eclipse_Ant_Java 7 - Fatal编程技术网

Java 使用Ant&;Eclipse,结果不一样

Java 使用Ant&;Eclipse,结果不一样,java,eclipse,ant,java-7,Java,Eclipse,Ant,Java 7,当我使用Eclipse运行下面的代码时,它工作正常(能够停止服务) 但是如果我使用Ant运行代码,下面的代码将无法停止服务 jdk1.7.0_17 apache-ant-1.9.0 Process p =Runtime.getRuntime().exec( new String[] {"cmd.exe", "/c", "Sc", "\\\\serverName", "STOP", "ServicenName" }); BufferedReader in = new BufferedR

当我使用Eclipse运行下面的代码时,它工作正常(能够停止服务) 但是如果我使用Ant运行代码,下面的代码将无法停止服务

jdk1.7.0_17 apache-ant-1.9.0

 Process p =Runtime.getRuntime().exec( new String[] {"cmd.exe", "/c", "Sc",  "\\\\serverName", "STOP", "ServicenName" });   
 BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));  
 String line = null;  
 while ((line = in.readLine()) != null) {  
   System.out.println(line);  
 } 
请告诉我原因


添加URL“使用Ant运行代码”时,您到底在做什么?你能给我们看剧本吗?亨利,谢谢你的回复。我已经在问题中添加了build.xml文件的URL。安装Sysinternals。在“流程启动”和“流程退出”操作上设置过滤器。比较在Eclipse中运行代码和使用Ant运行代码的结果。这应该澄清问题的根源。