Java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String

apachejava

I am trying a encrypt a plain text using org.apache.commons.codec.binary.Base64. When I call the method org.apache.commons.codec.binary.Base64.encodeBase64String(aByteArray), it gives the following exception

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String([B)Ljava/lang/String;

I am using the jar, org-apache-commons-codec.jar. Please help me as I can't understand What is wrong with this.

Best Solution

First of all encoding is not encryption. You are only changing representation of your string while encoding, it is easily changed back.

Since you are getting this exception this means that you at least have this jar in your classpath. Open this jar with a suitable zip tool like 7-zip and look at your Manifest.mf file. Your jar version should be greater than 1.4 according to Base64javadoc. Download latest version and replace your older version.

Related Question