getting an error: CreateProcess error=2, The system cannot find the file specified

0

I am getting an error:

Runtime Exception e = java.io.IOException: Cannot run program "pcsc.SCardTransmit(cardHandle,": CreateProcess error=2, The system cannot find the file specified

See the code below. Anybody know how I should create the command used in the Runtime statement?

//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
        }
    }
}
java
command
runtime
asked on Stack Overflow Mar 25, 2019 by Jim Coon

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0