Reputation: 1049
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("[email protected]", "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().
Upvotes: 1
Views: 5392
Reputation: 339
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.
Upvotes: 0
Reputation: 21
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("[email protected]", "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();
}
}
}
Upvotes: 1