1

This question has been asked several times but none of the solutions work for me. I running the DOS command window as Administrator, but when running the keytool command to install a certificate I get the error above:

C:\Program Files\Java\jdk1.8.0_191\jre\lib\security>keytool -import -file xxx.yyy.zzz.crt -alias xxxx.yyy.zzz.com -keystore cacerts -storepass changeit -noprompt
Certificate was added to keystore
keytool error: java.io.FileNotFoundException: cacerts (Access is denied)

I'm on Windows 10 with JDK 1.8.0_191. Why would access be denied to the Administator?

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
  • Seems to be the same [issue](https://stackoverflow.com/questions/10321211/java-keytool-error-after-importing-certificate-keytool-error-java-io-filenot). Please have a look. – Bibin Feb 04 '20 at 09:58

3 Answers3

5

"Run as administrator Command prompt" has fixed this issue at Windows.

RoutesMaps.com
  • 1,628
  • 1
  • 14
  • 19
4

I have faced the same issue.

Here is the solution what I found:

  1. Copy the cacert file other than Java folder [May be D drive or desktop].
  2. Update the path of cacert file path in your command [Sated in question].
  3. Run your query. [You wont get the io exception].
  4. Then replace the new cacert file in the original location.
shuberman
  • 1,416
  • 6
  • 21
  • 38
Bibin
  • 41
  • 3
1

My problem was that I did not have true admin rights to my Windows 10 laptop. I had enough permissions to install the JDK to the default location (which requires admin rights), but not enough rights to use keytool.

I uninstalled the JDK from the default location and reinstalled it in a directory that was not restricted to admin users. Then keytool worked properly.

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165