I am working on an Java application which uses smartcardio
to work with smartcard.
It must be possible to have one removing its USB card reader and then inserti
(This is just a comment but I don't have enough rep to post comments.)
The service it refers to is the Windows Smart Card service, also known as the smart card resource manager. If you open the Services MMC console you'll see it there with the startup type set to Manual (Trigger Start). In Windows 8 this service was changed to run only while a smart card reader is attached to the system (to save resources) and the service is automatically stopped when the last reader is removed. Stopping the service invalidates any outstanding handles.
The native Windows solution is to call SCardAccessStartedEvent and use the handle it returns to wait for the service to start before using SCardEstablishContext to connect to the resource manager again.