Your application (in Java, or in C/C++) can
use the private key stored in the YubiKey by telling the token to perform operations with that key (and supplying the correct PIN) - but there's no way (short of bringing a government lab and destructive equipment
to [b/extract[/b] the key from the token. That is by design, and is the main reason people buy YubiKey and other similar devices.
For normal public-key cryptography look up PKCS#11 access. Useful references:
P.S. I haven't tried to actually program U2F (only "normal" PK processing using RSA and ECC) - but am pretty sure the approach would be rather similar.