4
試圖實現從https://developers.google.com/google-apps/calendar/quickstart/java採取谷歌日曆的代碼,但如下得到了一個錯誤:得到了錯誤,同時運行日曆API示例代碼
Exception in thread "main" java.lang.NoClassDefFoundError: org/mortbay/jetty/Handler
at CalendarQuickstart.authorize(CalendarQuickstart.java:76)
at CalendarQuickstart.getCalendarService(CalendarQuickstart.java:89)
at CalendarQuickstart.main(CalendarQuickstart.java:101)
Caused by: java.lang.ClassNotFoundException: org.mortbay.jetty.Handler
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
和該行
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
在此之前,我只是從https://developers.google.com/google-apps/calendar/quickstart/java複製代碼並創建了Java項目,並且這兩個Jar文件丟失了
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
導入這些jar文件後出現該錯誤。請幫忙
感謝您的回答。但我不使用gradle構建。我試圖用.jar文件運行,但沒有得到確切的jar文件,我嘗試了上面提到的jar文件,但同樣的問題發生。 –
@Rahul如果您嘗試從頭開始刪除所有庫並運行構建清單(如果它是Maven或Ant)並且在構建之後清理項目,那麼有時這會有所幫助。您的工作空間中可能會有些東西無法找到JAR文件。 – Andres