編輯時org.apache.commons.codec.binary.Base64:拋出java.lang.ClassNotFoundException:試圖創建CommonsHttpOAuthConsumer
public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
System.out.println("debug1");
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer("key","secret");
System.out.println("debug2");
...}
喜當我嘗試運行此腳本,我得到這樣的響應:
DEBUG1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at oauth.signpost.signature.OAuthMessageSigner.<init>(OAuthMessageSigner.java:37)
at oauth.signpost.signature.HmacSha1MessageSigner.<init>(HmacSha1MessageSigner.java:30)
at oauth.signpost.AbstractOAuthConsumer.<init>(AbstractOAuthConsumer.java:65)
at oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.<init>(CommonsHttpOAuthConsumer.java:30)
at mein.tester.main(tester.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more
線21是
System.out.println("debug2");
0前行
嗯,我可以很容易地在eclipse中編譯代碼,並且我添加了2個Signpost librabrys以及common-codec.jar作爲外部庫,因爲我在另一篇文章中讀到了..但是,如何使它在運行時可用?在「添加到WEB-INF/lib」 - >我創建了該文件夾並添加了罐子 -i也嘗試了defaultoauthconsumer->同樣的錯誤
你的classpath中是否有所有必需的jar? – Wug