问题
I have some code in my Activity class that uses sun.misc.BASE64Encoder class. But it is showing "java.lang.NoClassDefFoundError : sun.misc.BASE64Encoder". Do i need the jar? Where can I download it from? Please help me.
回答1:
Don't use sun.*
classes. For Base64 in Android, use it's 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.
回答2:
It's available in rt.jar, that comes with Sun java runtimes.
In 1.5.0_06 : jre\lib\rt.jar
回答3:
- Just add rt.jar to the build path of the project from path
C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\lib
- Copy the jar and paste in the libraries folder of the project.
来源:https://stackoverflow.com/questions/7102605/how-to-get-the-jar-file-for-sun-misc-base64encoder-class