编辑:
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");
我可以轻松地在eclipse中编译代码,我添加了2个Signpost librabrys和common-codec.jar作为我在另一篇文章中读取的外部库..但是,我如何在运行时使它可用?(我做了就像在帖子“将它添加到WEB-INF / lib” - &gt;我创建了该文件夹并添加了jar -i还尝试了defaultoauthconsumer - &gt;同样的错误
答案 0 :(得分:1)
右键单击jar并选择&#34;添加到构建路径&#34;?我不认为ide会自动将它添加到你的类路径中,除非你告诉它。