I have the following snippet and I have some unresolved classes - mainly, Base64
String auth = username + ":" + password;
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
String authHeader = "Basic " + new String(encodedAuth);
request.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
I've tried to import the commons-codec maven repository but in Eclipse it still says cannot resolve class:
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.12</version>
</dependency>
We're kinda stuck for now using JDK7 which may be the issue. Is this Base64 class only available from Java 8? Otherwise, how do I import it into my application?
java.util.Base64class is only available in java 8+. The reason you can't see the one fromcommons-codecis not your java version. Please check your project configurationcommons-codec1.12. Do you have the right import ?import org.apache.commons.codec.binary.Base64;