0

I'm trying to run the sample program, which comes with Google Data API. I get a runtime error at following line

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

The error is the following:

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)

I tried both Google Data API versions 1.35.0 and 1.35.1, and I get the same error in both cases.

dnet
  • 1,411
  • 9
  • 19
user93796
  • 18,749
  • 31
  • 94
  • 150

2 Answers2

3

Looks like you don't have the collections library in your class path.

It's in the gdata/java/deps directory in the zip file. Include the google-collect-1.0-rc1.jar file in your classpath and you should be fine. (You may also need jsr305.jar - I'm not sure.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • i tried to download google-collect-1.0-rc1.jar ,from http://code.google.com/p/gdata-java-client/source/browse/#svn/trunk/java/deps, but i get a file of only 32 kb when the actual size shown on that site is 535 kb is there any other location when i can get this file? Can u mail it to me. my email id is mindedges@gmail.com – user93796 Aug 11 '09 at 08:49
  • You don't need to download it separately - it's in the GData API zip file. – Jon Skeet Aug 11 '09 at 08:58
2

Three little steps:

Stephan
  • 41,764
  • 65
  • 238
  • 329