adding certificate to the keystore code example
Example 1: how to add new certificate to jks file
keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias"
Example 2: add certificate to java truststore
# Copy the certificate into the directory Java_home\Jre\Lib\Security
# Change your directory to Java_home\Jre\Lib\Security>
# Import the certificate to a trust store.
keytool -import -alias ca -file somecert.cer -keystore cacerts -storepass changeit [Return]
Trust this certificate: [Yes]