To import an already existing certificate to keystore (whether trusted certificate signed by a trusted root certificate authority or a self-signed certificate):
keytool -importcert -alias somealias -keystore keystore.jks -file yourcert.cer
To import an already existing certificate to keystore (whether trusted certificate signed by a trusted root certificate authority or a self-signed certificate):
keytool -importcert -alias somealias -keystore keystore.jks -file yourcert.cer