在Ubuntu14.04下使用InstallCert.java安装证书时报错:
Loading KeyStore /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts...
Exception in thread "main" java.io.FileNotFoundException: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at InstallCert.main(InstallCert.java:81)
查看/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security目录:
root@ubuntu:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security# ls -lh
total 8.0K
lrwxrwxrwx 1 root root 46 Jul 26 20:45 blacklisted.certs -> /etc/java-8-openjdk/security/blacklis
lrwxrwxrwx 1 root root 27 Jul 26 20:45 cacerts -> /etc/ssl/certs/java/cacerts
lrwxrwxrwx 1 root root 40 Jul 26 20:45 java.policy -> /etc/java-8-openjdk/security/java.policy
lrwxrwxrwx 1 root root 42 Jul 26 20:45 java.security -> /etc/java-8-openjdk/security/java.securit
-rw-r--r-- 1 root root 639 Jul 26 19:54 local_policy.jar
lrwxrwxrwx 1 root root 36 Jul 26 20:45 nss.cfg -> /etc/java-8-openjdk/security/nss.cfg
-rw-r--r-- 1 root root 621 Jul 26 19:54 US_export_policy.jar
发现cacerts是一个相当于windows下的快捷方式
在Stack Overflow找到了这个相关的问题
This is due to a bug already reported here: Ubuntu bug ticket
The ticket above links another similar issue, which provides a workaround:
$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java
执行完上面两条命令后又查看了一下证书所在的目录:
root@ubuntu:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security# ls -lh
total 8.0K
lrwxrwxrwx 1 root root 46 Jul 26 20:45 blacklisted.certs -> /etc/java-8-openjdk/security/blacklisted.certs
lrwxrwxrwx 1 root root 27 Jul 26 20:45 cacerts -> /etc/ssl/certs/java/cacerts
lrwxrwxrwx 1 root root 40 Jul 26 20:45 java.policy -> /etc/java-8-openjdk/security/java.policy
lrwxrwxrwx 1 root root 42 Jul 26 20:45 java.security -> /etc/java-8-openjdk/security/java.security
-rw-r--r-- 1 root root 639 Jul 26 19:54 local_policy.jar
lrwxrwxrwx 1 root root 36 Jul 26 20:45 nss.cfg -> /etc/java-8-openjdk/security/nss.cfg
-rw-r--r-- 1 root root 621 Jul 26 19:54 US_export_policy.jar
好像没变化。
再执行InstallCert.java安装证书,不报错了,表示成功了。
Stack Overflow原帖地址:https://stackoverflow.com/questions/33439905/is-the-cacerts-file-missing-in-ubuntu-15-10-and-openjdk-8-jdk