Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The import sun.misc.BASE64Decoder cannot be resolved when the project is imported into Eclipse

Tags:

java

base64

I have this old project which was implemented a long time ago, and it uses sun.misc.BASE64Decoder and sun.misc.BASE64Encoder. When I imported the project into Eclipse it is showing me the that their imports cannot be resolved to a valid object.

I have tried using all the recommended methods on Stack overflow like turning errors into warnings. For references here's a screenshot

Thanks in advance for the help :)

like image 209
Harsh Paradkar Avatar asked Oct 29 '25 19:10

Harsh Paradkar


1 Answers

If you're using JDK 8+ then the reason is likely that the package for Base64Encoder and Base64Decoder has changed from sun.misc to java.util (see Is Java 8 java.util.Base64 a drop-in replacement for sun.misc.BASE64?)

You could either use an older JDK or replace the package.

Normally you don't have to expect the JDK packages to change - except for javax.* and sun.*. As far as I know these packages were originally for vendor specific or experimental classes and IIRC the Java docs explicitly mention that this could change - although this rarely happens.

like image 169
Stefan Rother-Stübs Avatar answered Oct 31 '25 08:10

Stefan Rother-Stübs