java - DebugPlugin.exec() 的用途

标签 java eclipse ant

我试图了解 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/

相关文章:

android cordova phonegap config.xml 未绑定(bind)前缀

eclipse - 通过使用xpath,如何在Eclipse中通过Selenium Webdriver打印类名称

ant - 我如何使用 ant build 在 Flash Builder 4 中执行 exportReleaseBuild 任务

java - 在 ant 脚本中运行 GWTComplier 时出现问题

Java HttpClient 关于 Cookie 的问题

java - Android getIntent().getExtras() NullPointerException

java - 如何修复 android-eclipse HelloWorld 应用程序?

java - 在旧 Java 版本上运行应用程序

java - deleterow() 仅适用于可更新的结果集

ant - 如何让 Ant INCLUDE 文件集优先于 EXCLUDE