0

I'm trying to use Parallel for loops from https://github.com/tantaman/commons. After importing the code to Eclipse, I get the error from the following function

public static String asURLSafeBase64String(UUID uuid) {
    try {
        return URLEncoder.encode(Base64Utils.trim(new sun.misc.BASE64Encoder().encode(UUIDUtils.asByteArray(uuid))), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return "";
}

with the following error

Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_25\lib\rt.jar')

I'm using Java 8 by the way. How can I resolve this error?

Magnilex
  • 11,584
  • 9
  • 62
  • 84
LifeAndHope
  • 674
  • 2
  • 10
  • 27
  • Seems like you dont have access to your Java folder on your Windows. If you cannot amend the access, try installing JDK into different location. – Zyga Jan 21 '15 at 17:22
  • possible duppicate http://stackoverflow.com/questions/5549464/import-sun-misc-base64encoder-got-error-in-eclipse – emeraldjava Jan 21 '15 at 17:23
  • i am guessing they finally removed that encoder (it's been considered deprecated for several versions). iirc, java 8 introduced an "official" base64 encoder/decoder, you should be using that. – him Jan 21 '15 at 17:59

1 Answers1

0

Switched back to Java version 7 solved the problem.

LifeAndHope
  • 674
  • 2
  • 10
  • 27