How to start JCOPShell (jcshell.bat) which is an NXP product from a custom Java Desktop Application [duplicate]

StackOverflow https://stackoverflow.com/questions/21138079

Question

I am trying to create a desktop application (created in java) which will internally run jcshell (tool from NXP which is used to interact with secure element SD card from computer) and produce the output. In jcshell I will be running script file. So this desktop application also should start jcshell internally and run the script file.

I have executed JCOP shell commands which will communicate to secure element SD card through JCOP shell tool (jcshell.bat) provided by JCOP(NXP). Now I need to create a windows desktop application through which I should be able to run JCOP shell commands through jcshell.bat.

Process processObj = Runtime.getRuntime().exec("cmd /C dir");

The above code will return same output from command prompt as well as from my custom java desktop application with details of the directory. I am looking for something similar , but could not get jcshell.bat running from my JavaDesktopApplication.

Any help on the above will be really appreciated

I have tried to work with ProcessBuilder also in the following way, but could not get the expected output.In the following arraylist, first element is the path of my batch file and second element is the location of script file.My intention is to run the script file through windows application which is jcshell.bat which I used to run with the tool given by JCOP.Following is the code using ProcessBuilder.

ArrayList commandList = new ArrayList<String>();
commandList.add("C:\\Program Files\\NXP Semiconductors\\JCShell\\jcshell.bat");
commandList.add("./scripts/javatest.jcsh");‌​‌​
ProcessBuilder pb = new ProcessBuilder(commandList);
pb.redirectErrorStream(true);
Process p = pb.start();
String s;
BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = stdout.readLine()) != null && !isCancelled()) {
    publish(s);
    System.out.println("OUTPUT == " + s);
}
if (!isCancelled()) {
    status = p.waitFor();
}
p.getInputStream().close();
p.getOutputStream().close();
p.destroy();
Was it helpful?

Solution

The answer is exactly given over here.. [Stackoverflow] (How to execute cmd commands via Java) Thank you all for the support given...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top