构建 gdata Java 程序
我被困在开发之初。我有一个简单的测试程序,如下所示。我关注了 http://code.google.com/apis/gdata/articles/eclipse .html 设置 Eclipse。
import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
public class Test {
public static void main(String[] args) {
YouTubeService service = new YouTubeService(
"xxx.apps.googleusercontent.com",
"AAA");
}
}
}
当我在控制台中运行 java Test
时,出现异常:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gdata/client/youtube/YouTubeService
at Test.main(Test.java:18)
Caused by: java.lang.ClassNotFoundException: com.google.gdata.client.youtube.YouTubeService
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
当我在 Eclipse 中运行时,出现异常:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at Test.main(Test.java:18)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 4 more
这里出了什么问题?如何解决这个问题?
I am stuck at the beginning of the development. I have a simple test program listed below. I followed http://code.google.com/apis/gdata/articles/eclipse.html to setup Eclipse.
import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
public class Test {
public static void main(String[] args) {
YouTubeService service = new YouTubeService(
"xxx.apps.googleusercontent.com",
"AAA");
}
}
}
When I run java Test
in console, I got exception:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gdata/client/youtube/YouTubeService
at Test.main(Test.java:18)
Caused by: java.lang.ClassNotFoundException: com.google.gdata.client.youtube.YouTubeService
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
When I run in Eclipse, I got the exception:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:555)
at Test.main(Test.java:18)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 4 more
What's wrong here? How to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎缺少 google-collections API,该 API 已被弃用,现已由guava 解决你的第二个错误(在 Eclipse 中运行)。对于第一个错误,您忘记将所需的 jar 添加到类路径 (gdata-youtube-2.0.jar)。使用
其中 ... 表示其他所需的库。
You seem to be missing google-collections API which has been deprecated and is now replaced by guava for your second error (running in eclipse). For the first error you have forgotten to add the required jars to you class path (gdata-youtube-2.0.jar). use
where ... symbolizes other required libraries.