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

只谈情不闲聊 提交于 2019-12-30 23:34:07

问题


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:


  1. Just add rt.jar to the build path of the project from path C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre\lib
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!