user5309974 user5309974 - 5 months ago 11x
Java Question

sending txt message using twilio Java and processing

I am trying to send a text message using Twillio API. I have to import the following libraries

import java.util.*;
import com.twilio.sdk.*;
import com.twilio.sdk.resource.factory.*;
import com.twilio.sdk.resource.instance.*;
import com.twilio.sdk.resource.list.*;

I program in processing! Can anyone explain to me how do I import those libraries in processing. thank you


You're actually talking about two separate issues: setting your classpath and importing things from the classpath.


Your classpath is all of the code you have access to in your sketch. It's generally a list of library jars, as well as the JDK.

So your first step is to add the jars to your Processing sketch. Here is a description of how to add a library to a Processing sketch. This is the same as setting your classpath. Find the Twilio library for Processing, or add the jar to your sketch directory manually.

Note that java.util is part of standard Java, so you don't have to add it to your sketch. It's already there.


Once you have the appropriate libraries added, you can use the classes and methods on your classpath. You could use their fully qualified name by including the package information like this:

void setup(){
   java.util.Date d = new java.util.Date();

But that can get annoying, so instead, you can tell Processing where to look for unqualified names by importing them:

import java.util.Date;

void setup(){
   Date d = new Date();

Note that import statements don't actually do anything. They don't "add" a library to your sketch. They just tell your code where to look for classes. And those classes have to be on your classpath first.

What Next

If you still can't get it working, post the specifics of what you've tried and any errors you're receiving, and we'll go from there.