0

I'm tring to:

import sun.security.provider.SecureRandom;

And Eclipse is suggesting me to Search repositories for 'sun.security.provider'. It can see only the java.security.SecureRandom...

Access restriction: The type 'SecureRandom' is not API (restriction on required library '/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar')

My BuildPath has the JRE System Library [JavaSE-1.7]

What can I check?

pittuzzo
  • 493
  • 8
  • 29
  • 2
    Content of `sun` package tends to change between Java versions so we are discouraged from using it your apps. Maybe instead use `java.security.SecureRandom`. – Pshemo Dec 06 '14 at 18:11

1 Answers1

0

The libraries in Eclipse have Access rules, so you cannot use every class (although they are present). These rules include the java.*, javax.* and the org.* packages (screenshot below).

When you change the library to use a specified JRE/JDK there are no access rules (second screenshot). You can change them by selecting the library and pressing the "Edit..."-button on the right side. In the new window you choose "Alternate JRE" (third screenshot).

But what Pshemo said is correct, too, you should not use these libraries.


JRE with Access rules:
Eclipse BuildPath

JRE without Access rules:
Eclipse BuildPath

Dialog:
Eclipse BuildPath

Community
  • 1
  • 1
herrlock
  • 1,454
  • 1
  • 13
  • 16