构建 gdata Java 程序

发布于 2024-12-24 19:14:15 字数 2371 浏览 0 评论 0原文

我被困在开发之初。我有一个简单的测试程序,如下所示。我关注了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2024-12-31 19:14:15

您似乎缺少 google-collections API,该 API 已被弃用,现已由guava 解决你的第二个错误(在 Eclipse 中运行)。对于第一个错误,您忘记将所需的 jar 添加到类路径 (gdata-youtube-2.0.jar)。使用

java -cp ...gdata-youtube-2.0.jar... your.java.Program

其中 ... 表示其他所需的库。

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

java -cp ...gdata-youtube-2.0.jar... your.java.Program

where ... symbolizes other required libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文