An error was received when starting the Api Sample Code calendar

tried to embed a google calendar code taken from https://developers.google.com/google-apps/calendar/quickstart/java but got the following error:

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

And the line was

 Credential credential = new AuthorizationCodeInstalledApp(
        flow, new LocalServerReceiver()).authorize("user");

Before that, I just copied the code from https://developers.google.com/google-apps/calendar/quickstart/java and created a Java project, and this two Jar files were missing

import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;

After importing these jar files, this error is received. Please, help

+4
source share
1 answer

Google Calendar API Java Quickstart . , , . Gradle build ( , "Gradle Depenencies" jar - jetty-6.1.26.jar.

, build.gradle , , .

dependencies {
     compile 'com.google.api-client:google-api-client:1.20.0'
     compile 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
     compile 'com.google.apis:google-api-services-calendar:v3-rev125-1.20.0'
}

, Gradle, . !:)

!

0

Source: https://habr.com/ru/post/1619023/


All Articles