编程语言
首页 > 编程语言> > YouTube Java API问题

YouTube Java API问题

作者:互联网

我正在尝试使用YouTube Java GData库/ API获取特定用户的视频列表.

但是,当我尝试使用YouTubeService service = new YouTubeService(“Cyphon-MyCampusPulse-1”,YOUTUBE_API_KEY);创建服务时,我收到以下运行时异常:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at scrapers.YouTubePulseScraper.<init>(YouTubePulseScraper.java:37)
at scrapers.YouTubePulseScraper.main(YouTubePulseScraper.java:153)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more

我不确定异常与我正在做的事情有什么关系.任何提示都表示赞赏.

解决方法:

您需要将JavaMail jar添加到包含javax.mail.MessagingException的类路径中.你可以在这里得到它:http://www.oracle.com/technetwork/java/index-138643.html

编辑:
从文档中提取:

The GData Java Client Library has the
following external dependencies. The
following sections will describe how
to install these dependencies on your
favorite operating system (or the OS
that you’re stuck with at work).

  • JDK (Java Development Kit) version 1.5+
  • Apache Ant version 1.7+
  • mail.jar in Sun’s JavaMail API 1.4+
  • activation.jar in Sun’s JavaBeansActivationFramewrok. This is
    only required for media specific APIs
    including Document List Data API,
    Picasa Web Album API, and YouTube Data
    API.
  • servlet.jar in Sun’s Servlet API version 2.3+. This is required only if
    executing code samples in
    ‘sample.authsub’ or
    ‘sample.gbase.recipe’ packages.

A few of the .jar dependencies are
only required for specific samples,
but to avoid build errors, it’s best
just to get everything. Choose your
operating system of choice to
continue:
07001,
07002,
or
07003.

我已经添加了这个,因为如果你错过了一个依赖关系,你可能会错过其他依赖关系,所以你应该仔细检查你有什么.

标签:java,youtube,youtube-api,gdata-api
来源: https://codeday.me/bug/20190526/1158258.html