我被困在開發的開始。我有一個簡單的測試程序列在下面。我遵循http://code.google.com/apis/gdata/articles/eclipse.html來設置Eclipse。構建一個gdata Java程序
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
這裏有什麼錯?如何解決這個問題?
似乎需要JAR文件丟失。確保你需要Jars文件在project-lib文件夾中。 – kosa 2012-01-03 21:34:22