title: Maven can't compile using rt.jar
body: <p>My project uses <code>sun.security.tools.keytool</code> to generate certificate under JDK 1.8 and this package can be found in <code>rt.jar</code>. According to <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies" rel="nofollow noreferrer">Introduction to the Dependency Mechanism, System Dependencies</a>, I can add <code>rt.jar</code> as a dependency to my project:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;sun.jdk&lt;/groupId&gt;
    &lt;artifactId&gt;rt.jar&lt;/artifactId&gt;
    &lt;version&gt;1.8&lt;/version&gt;
    &lt;scope&gt;system&lt;/scope&gt;
    &lt;systemPath&gt;${java.home}/lib/rt.jar&lt;/systemPath&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I'm pretty sure Maven found this jar file. However when I import <code>sun.security.tools.keytool.Main</code>, it still generates an error. Moreover, the most strange thing is if I copy <code>rt.jar</code> into someplace and fill its path in <code>pom.xml</code>, it works! As soon as I switch back to use the original <code>rt.jar</code>, it fails!</p>
  
  <p>Can anyone tell me how could this happen?</p>