Import Sun.Misc.Base64Encoder Results in Error Compiled in Eclipse

import sun.misc.BASE64Encoder results in error compiled in Eclipse

That error is caused by your Eclipse configuration. You can reduce it to a warning. Better still, use a Base64 encoder that isn't part of a non-public API. Apache Commons has one, or when you're already on Java 1.8, then use java.util.Base64.

is the sun.misc package still available in java?

I suggest you forget about the sun.misc.BASE64Encoder and use Apache Commons Base64 class. Here is the link: http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html


Update (6/7/2017)

Using sun.misc.BASE64Encoder will cause a compilation error with Java 9 and it is already giving a warning in Java 8.

The right class to use is Base64 in java.util package.

Example:

import java.util.Base64;

Base64.getDecoder().decode(...);

How to get the JAR file for sun.misc.BASE64Encoder class?

Don't use sun.* classes. For Base64 in Android, use its native class or add a library to your project that does this (Apache commons, etc.). Alternatively just copy the Android source code to your project (in your own package), if you need to use it on pre-2.2 devices.

sun.misc.BASE64Decoder showing error in java application

Don't use classes in the sun.misc package. These are deprecated and terrible. Check out Apache commons codec for base64 encoding and decoding. Why not to use sun.misc.* classes



Related Topics



Leave a reply



Submit