I created Java keystore programmatically of type jks (i.e. default type). It is initially empty so I created a DSA certificate.
keytool -genkey -alias
No, you cannot. You can access the private key from code, but you cannot export it using the keytool. Use OpenSSL if you need to export private key.
Another option: you can generate keystore in PKCS12 format. Then you can import it to a browser and then to export the private key.