I'm trying to convert old project into maven project. But when project is maven then it shows warnings on class with import:
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
Access restriction: The type 'BASE64Decoder' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')
So what is the problem with it?
Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace. I followed the above steps and the issue is resolved.
Access restriction: The type 'BASE64Decoder' is not API (restriction on required library 'C:\Program Files\Java\jre7\libt.jar') So what is the problem with it? You can either replace sun.misc.BASE64Encoder & sun.misc.BASE64Decoder with other BASE64 class e.g. Apache commons or use:
And now error Access restriction: The type 'Application' is not API (restriction on required library rt.jar) is solved. 10 points on why we are still using primitive data types in java ?
Solved : Access restriction: The type 'Application' is not API (restriction on required library rt.jar) 1 Step 1.1: click Windows, Preferences, 2 Step 1.2: Type jre 3 Step 1.3: Select Standard VM > 4 Step 1.4: JRE home and JRE name More ...
You can either replace sun.misc.BASE64Encoder & sun.misc.BASE64Decoder with other BASE64 class e.g. Apache commons or use:
java.util.Base64;
Base64.getDecoder().decode(...);
Base64.getEncoder().encodeToString(...);
All sun.* and com.sun.* packages are private to a Java implementation. Any future release of Java may alter them, possibly in ways which may break application code that relies on them.
In contrast, all classes in java.*, javax.* and javafx.* packages are set in stone. Their names and their public members will not change and will not be removed (except, in theory, the deprecated ones).
That is why you’re getting a message that those classes are not part of the public API. They are not meant for public consumption.
As of Java 8, you should be using java.util.Base64 instead. However, it looks like you’re using Java 7, so you’ll want to use DatatypeConverter.parseBase64Binary and DatatypeConverter.printBase64Binary instead.
It should also be mentioned that Java 9, which is expected to be released in July 2017, will not allow programs to access sun.* classes. See https://mreinhold.org/blog/jigsaw-module-system .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With