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
  • 8,815
  • 19
  • 85
  • 143
  • 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

3

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.
mishsx
  • 1,265
  • 5
  • 19
  • 34
Bibin
  • 31
  • 3
2

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

RoutesMaps.com
  • 1,485
  • 1
  • 12
  • 18
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
  • 8,815
  • 19
  • 85
  • 143