have a
look at the demo demo.pkcs.pkcs11.GenerateKeyPair of the PKCS#11 wrapper. at the
end of this demo, you can see how to convert the public key that you get from
the wrapper into a public key for Java.

I am generating and saving my Keys [public and
private] in HSM. In my software i generate PKCS10 request for my certificate
to be generated from a CA. I get the Public key from HSM but i can not save
that in PKCS10 request becuase JAva class for Key in HSM is entirely
different from the Java class for Public Key in X509Certificate. How can i
convert public key in HSM to PublicKey class in X509Certificate. or if i
have to save Pubic key in HSM how can i save it in PublicKey member of
X509Certificate class.