我想从eclipse启动mysql服务器,我需要管理员权限来启动它,我该怎么做?
import java.io.*;
public class Clasa {
public static void main(String args[]) {
try {
String command = "net start MySql55";
ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C", command);
pb.inheritIO();
Process pr = pb.start();
int exitVal = pr.waitFor();
System.out.println("Exited with error code " + exitVal);
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
答案 0 :(得分:0)
This is really something that a scripting language (python, batch file) would be a better fit for. That being said, you can look here for more info on doing this in Java.