1

I am trying to import a file which is in the jar file. I have used many versions of the jar file but i cannot able to figure out which version of the jar will support that import statement.

This is the statement that i am trying to import

import com.google.appengine.repackaged.com.google.common.util.Base64;

and this is the jar file link that i have downloaded and added to my eclipse project classpath

http://www.java2s.com/Code/Jar/a/Downloadappengineapi120jar.htm

Please help in importing the above statement with a suitable jar file. Thanks in advance

public void String signPolicyDocument(String policyDocument, String secret) {
                try {
                    Mac mac = Mac.getInstance("HmacSHA1");
                    byte[] secretBytes = secret.getBytes("UTF8");
                    SecretKeySpec signingKey = 
                        new SecretKeySpec(secretBytes, "HmacSHA1");
                    mac.init(signingKey);
                    byte[] signedSecretBytes = 
                        mac.doFinal(policyDocument.getBytes("UTF8"));
                    String signature = Base64.encode(signedSecretBytes);
                    return signature;
                } catch (InvalidKeyException e) {
                    throw new RuntimeException(e);
                } catch (NoSuchAlgorithmException e) {
                    throw new RuntimeException(e);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                }
            }
Sreekanth
  • 534
  • 1
  • 5
  • 21
  • read this http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse – LMK May 27 '14 at 11:31
  • thanks for the reply Mr latif. I know how to add jar to the eclipse class path. I am facing the problem that i can import the exact statement, but the imported statement showing error. – Sreekanth May 27 '14 at 11:33
  • what error it is showing? – LMK May 27 '14 at 11:35
  • Use of com.google.appengine.repackaged may result in your app breaking without warning is the error – Sreekanth May 27 '14 at 11:40
  • Do it as S. Moreno said https://groups.google.com/forum/#!topic/google-appengine-java/VitQvUDowvc – LMK May 27 '14 at 11:52

1 Answers1

3

Try to import org.apache.commons.codec.binary.Base64

S. Moreno
  • 526
  • 2
  • 7
  • 29
  • thanks for the response Mr. Moreno. But i am facing another scenario. Please do visit my edited question. I just want that code to be like that. And allows import statement. I checked that code from here under Listing #26. [link] http://www.ibm.com/developerworks/library/j-gaestorage/index.html?ca=drs – Sreekanth May 27 '14 at 11:37
  • I use commons codec for Base64. This is the correct answer. – Andrei Volgin May 27 '14 at 13:20
  • You can replace the Google.Base64 for Apache.Base64 without problem and your code changes a very little. – S. Moreno May 27 '14 at 13:22