Question: I'm trying to learn about how does Java access smart cards, due to a project analysis. I wonder if there is any kind of virtual smart card which I could use to make some tests with Java?

By the way, I've read about Java Card, and looks like it is used to run Java in cards, not to smart card data access using Java, right?

Answer: 
[Look at this tutorial + example](http://www.developer.com/java/other/article.php/10936_3587361_3/Java-Applet-for-Signing-with-a-Smart-Card.htm). And [related](http://www.nakov.com/documents-signing/). (I have used these examples and they work fine).

An important point is that you can't get anything out of the smart card. You can only send things to its processor. So whenever you get a `PrivateKey` object, you don't actually have the private key - this is only a proxy to the SmartCard processor, and calling methods on it, calls the processor.

I'm not aware of virtual smart cards, though.

An API of interest is [`javax.smartcardio`](http://java.sun.com/javase/6/docs/jre/api/security/smartcardio/spec/)
If you need to emulate JavaCard try to use jCardSim: <http://jcardsim.org>. 
It also supports access via javax.smartcardio API and apdu-scripts.