0

我正在尝试运行 Google Data API 附带的示例程序。我在以下行收到运行时错误

YouTubeService myService = new YouTubeService("gdataSample-YouTube-1");

错误如下:

run:
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:532)
        at YouTubeReadonlyClient.main(YouTubeReadonlyClient.java:713)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

我尝试了 Google Data API 版本 1.35.0 和 1.35.1,在这两种情况下我都得到了同样的错误。

4

2 回答 2

3

看起来您的类路径中没有集合库。

它位于gdata/java/depszip 文件的目录中。将文件包含google-collect-1.0-rc1.jar在您的类路径中,您应该没问题。(您可能还需要jsr305.jar- 我不确定。)

于 2009-08-11T08:26:30.397 回答
2

三个小步骤:

于 2011-02-06T05:15:56.380 回答