我试图了解 DebugPlugin.exec(String[] cmdLine, FileworkingDirectory)
方法到底是做什么的。
我第一次遇到这个方法是在文章How to write an Eclipse debugger中.
插件:core,包:pda.launching,类:PDALaunchDelegate,方法:launch
commandList.add(file.getLocation().toOSString());
int requestPort = -1;
int eventPort = -1;
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
requestPort = findFreePort();
eventPort = findFreePort();
if (requestPort == -1 || eventPort == -1) {
abort("Unable to find free port", null);
}
commandList.add("-debug");
commandList.add("" + requestPort );
commandList.add("" + eventPort );
}
String[] commandLine = (String[])
commandList.toArray(new String[commandList.size()]);
Process process = DebugPlugin.exec(commandLine, null);
IProcess p = DebugPlugin.newProcess(launch, process, path);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
IDebugTarget target = new PDADebugTarget(launch,p,requestPort,eventPort );
launch.addDebugTarget(target);
}
现在,我再次看到该方法通过 Ant 插件中的 AntLaunchDelegate
类。我没有得到的是命令行
。它是执行的指令集吗?我已经研究过 DebugPlugin
API,但我没有完全理解它。
最佳答案
此方法所做的只是调用运行程序的 Java Runtime.getRuntime().exec
方法。该方法对发生的任何错误添加了一些处理。
字符串数组中的第一个条目是要执行的程序的完整路径,数组的其余部分是要传递给程序的参数。
所以数组
new String[] {"/bin/ls", "-l"};
将指定使用参数-l
运行/bin/ls
命令。
关于java - DebugPlugin.exec() 的用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31832717/