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
.
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
Andmore's Android Package Builder fails with error related to sun/misc/BASE64Encoder
Looking at eclipse.ini
(in my Eclipse path), I found an explicit reference to JRE 11:
-vm
/usr/lib/jvm/java-11-openjdk-amd64/bin
After I changed that to
-vm
/usr/lib/jvm/java-8-openjdk-amd64/bin
I finally get an APK, and after cleaning the project once, I was able to install it on a device.
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(...);
NoClassDefFoundError: sun.misc.BASE64Decoder
I resolved the issue - details are found in this SO posting.
Why am I getting the error "NoClassDefFoundError: sun/misc/Unsafe" when trying to load sounds using the LWJGL library?
From your posted IDE screenshot I can see that you are using
- Java 12, and
- the Java Module System (
module-info.java
)
Note that sun/misc/Unsafe
is a (legacy) Java internal API which for that reason and by default is encapsulated (hidden) away when using the Java Module System.
In order for your application (and your used library) to access it, you need to explicitly include it in your module-info.java
by adding requires jdk.unsupported;
Alternatively, you may also not use the Java Module System – in which case it should simply work. However, I recommend to continue using the module system.
Related Topics
Tomcat Server Error - Port 8080 Already in Use
Java 8 Convert Utc Time to Edt/Est So That Date Remains the Same
Checking If a Document Exists in a Firestore Collection
Regex to Match a String Not Starting or Ending With a Pattern
How to Write a User Input Based Constructor
Java:Using Apache Poi How to Convert Ms Word File to Pdf
Duplicate Entry Exception: Spring Hibernate/Jpa Cascade Save Many to One
Spring Boot/Spring Kafka Ssl Configuration by Environment Variables Impossible
Spring Boot Could Not Resolve Placeholder in String
How to Mock a Generic Parameter for a Unit Test in Java
Selecting from Div Class Dropdown - Selenium
How to Change Read-Only Status of Files in Intellij
How to Get Values of All Elements from Xml String in Java
Mapstruct: Map List of Objects, When Object Is Mapped from Two Objects
How to Get Multiple Columns from Table Using Jpa