I am trying to pass scm command programmatically using java and trying to get the result of that particular command on eclipse console but i am unable to perform so,here is the approach that i followed :
public SCMCommand(final String repositoryURI, final String userId, final String password,
final String scmtoolspath, String streamName) {
this.repositoryURI = repositoryURI;
this.userId = userId;
this.password = password;
this.scmtoolspath = scmtoolspath;
this.streamName = streamName;
}
public void setCommand() throws IOException
{
String line;
String tempPath1 = this.scmtoolspath + "\\scm";
this.command = "cmd /c " + tempPath1 + " show operations -r " + this.repositoryURI + " -u "+ this.userId + " -P " + this.password + " " + this.streamName;
System.out.println(this.command);
ProcessBuilder processBuilder = new ProcessBuilder();
// Run this on Windows, cmd, /c = terminate after this run
processBuilder.command(this.command);
try {
Process process = processBuilder.start();
// blocked :(
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
int exitCode = process.waitFor();
System.out.println("\nExited with error code : " + exitCode);
}
catch (IOException e) {
e.printStackTrace();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Your Help will be appreciated, Thanks in advance!!!!
Also the output what i am getting on my console
java.io.IOException: Cannot run program "cmd /c C:\AB_TOOLS\ALMAddons\CodeReviewMetrics\libs\SCMTools\jazz\scmtools\eclipse\scm show operations -r ****8** -u **** -P **** streamName": CreateProcess error=2, The system cannot find the file specified
Build Result: All Streams Loaded Successfully
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.bosch.airbag.StreamHistory.SCMCommand.setCommand(SCMCommand.java:52)
at com.bosch.airbag.StreamHistory.App.main(App.java:75)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 2 more
Important Notes -The path of the file is correct -when i am running the given command i.e" cmd /c C:\AB_TOOLS\ALMAddons\CodeReviewMetrics\libs\SCMTools\jazz\scmtools\eclipse\scm show operations -r ****8** -u **** -P **** streamName" -its running fine on command prompt but not on eclipse ide