使用jdk生成keystore时sun.security.tools.keytool.CertAndKeyGen找不到问题总结

本文解决在使用JDK1.9生成keystore时遇到的CertAndKeyGen类找不到的问题,揭示了JDK1.9后对tool.jar和rt.jar的模块化管理变化,并提供将项目迁移到JDK1.8的步骤,包括Maven编译配置。

最近在使用jdk生成keystore时发现编译和运行报出sun.security.tools.keytool.CertAndKeyGen等相关包类找不到,经过研究发现是由于环境中的jdk是1.9导致,jdk1.9之后java删除了tool.jar和rt.jar,对其进行模块化管理,核心思想就是分解并加载尽量少的包。
既然如此,我还是决定换到jdk1.8,主要是也比较稳定也基本够用。同时要注意如果用maven编译,pom的依赖需要加入

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <verbose />
                        <bootclasspath>G:\Java\jdk1.8.0_201\jre\lib\rt.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
1 actionable task: 1 up-to-date bdlf@bdlf-desktop:~/AndroidUSBClient$ rm -rf ~/.gradle/caches/ bdlf@bdlf-desktop:~/AndroidUSBClient$ ./gradlew assembleDebug This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. IOException: https://dl.google.com/android/repository/addons_list-5.xml javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed IOException: https://dl.google.com/android/repository/addons_list-4.xml javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed IOException: https://dl.google.com/android/repository/addons_list-3.xml javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed IOException: https://dl.google.com/android/repository/addons_list-2.xml javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed IOException: https://dl.google.com/android/repository/addons_list-1.xml javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed Failed to download any source lists! IO exception while downloading manifest: javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321) 如何解决?
05-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值