Search code examples
javaintellij-ideaplayframeworksbt

IntelliJ says the package does not exist, But I can access the package


I get the error below, but I can find the package in rt.jar. I can see the JDK being used from Project Structure. I'm not sure what's missing.

Error:(6, -1) Play 2 Compiler: 
 C:\user\projects\portal\app\com\example\security\cert\X509Cert.java:6: package sun.security.pkcs10 does not exist
 import sun.security.pkcs10.*;
 C:\user\projects\portal\app\com\v\security\cert\GenerateCSR.java:75: cannot find symbol

Solution

  • This is not an intellij issue.

    You need to compile with the -XDignore.symbol.file option. Some internal packages are hidden by default unless you add this option to javac.

    https://bugs.openjdk.java.net/browse/JDK-7141442

    sun.security.x509.CertAndKeyGen and sun.security.pkcs.PKCS10 - missing in JDK8. Implementation suggestions

    Also the comment of user @user180100 is relevant and important.

    The sun.* packages are not part of the supported, public interface.
    A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.