Reputation: 49
I am trying to understand what exactly the DebugPlugin.exec(String[] cmdLine, File workingDirectory)
method does.
I first encountered this method in the article How to write an Eclipse debugger.
Plug-in: core, Package: pda.launching, Class: PDALaunchDelegate, Method: 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);
}
Now, I have seen the method again going through the AntLaunchDelegate
class in an Ant Plugin. What I don't get is commandline
. Is it set of instructions that are executed? I have already looked into the DebugPlugin
API, but I don't fully comprehend it.
Upvotes: 1
Views: 165
Reputation: 111216
All this method does is call the Java Runtime.getRuntime().exec
method which runs a program. The method adds a bit of processing on any errors that occur.
The first entry in the string array is the full path of the program to be executed, the rest of the array is arguments to be passed to the program.
So the array
new String[] {"/bin/ls", "-l"};
would specify that the /bin/ls
command is to be run with the argument -l
.
Upvotes: 1