[Solved] Project Error: Could not found sun.misc.BASE64Encoder

1. Questions

The project reported an error: could not found sun.misc.BASE64Encoder

2. Reason

Classes such as sun.misc.BASE64Encoder are not part of the JDK standard library, but the class is included in the JDK and can be used directly.

3. Solution

Replace sun.misc.BASE64Encoder with java.util.Base64

Example:

//import sun.misc.BASE64Encoder;
import java.util.Base64;//how to solve could not found sun.misc.BASE64Encoder error
...
// return new BASE64Encoder().encodeBuffer(bytes).trim().replaceAll("\r|\n", "");
return Base64.getEncoder().encodeToString(bytes);

Read More: