Question: I was encrypting some text, for which I used `BASE64Encoder`

```
String encryptedValue = new BASE64Encoder().encode(encVal);

```

But I am getting a warning

```
The constructor 'BASE64Encoder()' is not API (restriction on required library 'C:\Program Files (x86)\Java\jdk1.8.0_45\jre\lib\rt.jar')
The method 'CharacterEncoder.encode(byte[])' is not API (restriction on required library 'C:\Program Files (x86)\Java\jdk1.8.0_45\jre\lib\rt.jar')
Access restriction: The type 'BASE64Encoder' is not API (restriction on required library 'C:\Program Files (x86)\Java\jdk1.8.0_45\jre\lib\rt.jar')

```

I can suppress this warning by `@SuppressWarnings("restriction")`. But I want to know why I am getting this warning. Will it create problems later?

Answer: 
You should really avoid to call `sun.*` classes :

> 
> 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.
> 
> 
> 

[Why Developers Should Not Write Programs 
That Call 'sun' Packages](http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html)

Other libraries, like Apache Commons Codec will do what you need :

[Commons Codec Base64](https://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Base64.html)
You are probably using the import sun.misc.BASE64Encoder; which is deprecated in 1.8

You should go with the new base64 that exists on 1.8 (<https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html> ) or you can use apache common codec lib (which i use)

```
import org.apache.commons.codec.binary.Base64;

    String encryptedValue = new Base64().encodeToString(encVal);

```