This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / A java question about starting batch file via Runtime.exec.I met a question below:
I must start a service(jettyHttpserver) or a batch file via java. I use runtime.exec("cmd.exe /c a.bat ") or runtime.exec("cmd.exe /c psservice.exe start jettyHttpserver").But they donot work.In command line,It all work well. Who can tell me the reason?Thanks in advance!
-zlx(steven);
2001-5-4
{302}
(#60925@0)
-
try it. have fun!import java.io.*;
import java.util.*;
public class testExec{
public static void main(String args[]){
Runtime rt = Runtime.getRuntime();
try {
rt.exec("notepad.exe");
}catch(Exception e){
System.out.println(e);
}
}
}
-crayannie(心爱的人在加拿大);
2001-5-16
{262}
(#72025@0)