我遇到错误:
运行时异常e = java.io.IOException:无法运行程序“ pcsc.SCardTransmit(cardHandle,”:CreateProcess error = 2,系统找不到指定的文件
请参见下面的代码。有人知道我应该如何创建Runtime语句中使用的命令吗?
//Code snippet showing the command that causes the message
String command = "pcsc.SCardTransmit(cardHandle, cmd);";
Process process = null;
try {
process = Runtime.getRuntime().exec(command);
}
catch(Exception e){
System.out.println("\n\nRuntime Exception e = "+e);
}
ProcessWithTimeout processWithTimeout = new ProcessWithTimeout(process);
int exitCode = processWithTimeout.waitForProcess(5000);
System.out.println("\n\nexitCode = "+exitCode);
if (exitCode == Integer.MIN_VALUE) {
// Timeout
System.out.println("\n\nTimeout on SCardTransmit");
throw new PcscException("SCARD_E_TIMEOUT",0x8010000A);
}
else {
// No timeout !
}
//The methods called out by the code snippet above
public class ProcessWithTimeout extends Thread
{
private Process m_process;
private int m_exitCode = Integer.MIN_VALUE;
public ProcessWithTimeout(Process p_process)
{
m_process = p_process;
}
public int waitForProcess(int p_timeoutMilliseconds)
{
this.start();
try
{
this.join(p_timeoutMilliseconds);
}
catch (InterruptedException e)
{
this.interrupt();
}
return m_exitCode;
}
@Override
public void run()
{
try
{
m_exitCode = m_process.waitFor();
}
catch (InterruptedException ignore)
{
// Do nothing
}
catch (Exception ex)
{
// Unexpected exception
}
}
}