Problems with the Java Java API

I am trying to get a list of videos from a specific user using the YouTube GData Java library / API.

However, when I try to create a service using YouTubeService service = new YouTubeService("Cyphon-MyCampusPulse-1", YOUTUBE_API_KEY); I get the following exception at runtime:

 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 

I am not sure how this exception relates to what I am doing. Any hints are welcome.

+4
source share
2 answers

You need to add the JavaMail jar to your classpath that contains javax.mail.MessagingException. You can get it here: http://www.oracle.com/technetwork/java/index-138643.html

Edit: Extracted from documentation:

The GData Java client library is after external dependencies. the following sections will describe how to install these dependencies on your favorite operating system (or the OS that you are stuck with at work).

  • JDK (Java Development Kit) version 1.5+
  • Apache Ant version 1.7 +
  • mail.jar in Sun JavaMail API 1.4 +
  • activation.jar in Sun JavaBeansActivationFramewrok. This is only required for multimedia-specific APIs including the document list data APIs, Picasa Web Albums APIs, and YouTube APIs data.
  • servlet.jar in the Sun Servlet API version 2.3+. This is only required if executing code samples in 'sample.authsub' or 'sample.gbase.recipe'.

Some of the .jar dependencies are only required for specific samples, but to avoid build errors, it is better just to get everything. Choose your operating system of choice Continue: Windows , Mac OS X , or Linux .

I added this because if you are missing one dependency, you can skip the others, so you should double check that you have everything.

+7
source

You need Java Mail , which is available from the Maven Repository :

 <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.5</version> </dependency> 
0
source

All Articles