Actually, the examples you refer to were written for Java 7. Get the free ebook for which those examples were written and you'll read:
if you need to upgrade to make this example work on your OS, you may
want to avoid the 64-bit version of Java 7, and opt for the 32-bit
version. The SunPKCS11 provider is missing in the 64-bit version of
Java 6 as well as Java 7. We’ll need that provider in the next
chapter. There’s no ETA as to when Oracle will fix this problem.
That was written 3 years ago. You may want to check on the current status of that allegation.
As you know, all classes in sun
packages, such as sun.security.pkcs11.SunPKCS11
aren't really supported by Oracle. Read the answers to It is a bad practice to use Sun's proprietary Java classes?