Unable to import certificate to cacerts

keytool -importcert -trustcacerts -alias mycert -file c:\maven-cacert.cer.der -keystore "%JAVA_HOME%"\jre\lib\security\cacerts

You also had a problem with alias. It's a name, not a file. You need to quote the "%JAVA_HOME%", because it has a space inside.


If you are using OpenJDK then the path for cacerts will not be available in

"%JAVA_HOME%"/jre/lib/security/cacerts

it will be available in path

"%JAVA_HOME%"/lib/security/cacerts


Try using "%JAVA_HOME%\jre\lib\security\cacerts"


Use Bellow command to import the certificate in cacerts

  1. Run command prompt as Administrator
  2. cd C:\Program Files\Java\jdk1.6.0_45\jre\bin
  3. keytool -import -trustcacerts -file "certpath\certname.cer" -alias "cert_alias" -keystore "%JAVA_HOME%"/jre/lib/security/cacerts
  4. To view certificate keytool -list -keystore "%JAVA_HOME%"/jre/lib/security/cacerts -alias cert_alias