My project uses sun.security.tools.keytool
to generate certificate under JDK 1.8 and this package can be found in rt.jar
. According to Introduction to the Dependency Mechanism, System Dependencies, I can add rt.jar
as a dependency to my project:
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>rt.jar</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
I'm pretty sure Maven found this jar file. However when I import sun.security.tools.keytool.Main
, it still generates an error. Moreover, the most strange thing is if I copy rt.jar
into someplace and fill its path in pom.xml
, it works! As soon as I switch back to use the original rt.jar
, it fails!
Can anyone tell me how could this happen?