Access restriction: The type 'BASE64Decoder' is not API

Viewed 21561

I'm trying to convert old project into maven project. But when project is maven then it shows warnings on class with import:

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

Access restriction: The type 'BASE64Decoder' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')

So what is the problem with it?

2 Answers

You can either replace sun.misc.BASE64Encoder & sun.misc.BASE64Decoder with other BASE64 class e.g. Apache commons or use:

java.util.Base64;
Base64.getDecoder().decode(...);
Base64.getEncoder().encodeToString(...);
Related