I want to sent SMS from Google calendar with a Java application. I create a Java Desktop Application and add libraries gdata-calendar-2.0.jar
, gdata-client-1.0.jar
into Libraries.
After that, I create button and paste this code in jButton1ActionPerformed
:
CalendarService myService = new CalendarService("exampleCo-exampleApp-1.0");
myService.setUserCredentials("root@gmail.com", "pa$$word");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
System.out.println("Your calendars:");
System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry开发者_开发问答 = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
I have these imports:
import com.google.gdata.client.calendar.*;
import com.google.gdata.data.calendar.*;
but it shows cannot find symbol at setUserCredentials, getEntries(), getTitle().
Maybe your jar files are not set properly on the classpath?
I've tried your code above and it's working properly giving me the correct calendar names.
import java.net.URL;
import com.google.gdata.client.calendar.*;
import com.google.gdata.data.calendar.*;
public class GoogleTest {
public static void main(String[] args){
try{
CalendarService myService = new CalendarService("exampleCo-exampleApp-1.0");
myService.setUserCredentials("myaccount@gmail.com", "mypass");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
System.out.println("Your calendars:");
System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
}catch(Exception e){
e.printStackTrace();
}
}
}
i think i got the mistake u r making. please put download gdata-src.java-1.47.1.jar and in that you will find a gdata-core1.0.jar. Just put that in your lib folder by right clicking on the libraries and adding this jar from its location.
精彩评论