I try to create a new self certified keystore file
The command I use is:
keytool -genkey -selfcert -dname \"cn=My Name, ou=Orga unit\" -alias selfcer
Generating a key pair (and a new keystore) has to be done as a separate operation to creating a self-signed certificate for that key.
i.e.
keytool -genkey -alias myKey -keystore store.jks keytool -selfcert -alias myKey -keystore store.jks