I’m trying to make use of a java api for google voice (available here: http://code.google.com/p/google-voice-java/ ), google-voice-java-1.6.jar and json.jar
My program is not finding the .jar file for import. I’ve made sure my classpath is pointing to the dir containing the jar files.
My code below does not use any of the GV classes, I’m simply trying to import them. What am I doing wrong? The standard java classes import fine.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import gvjava.org.json.JSONException;
import gvjava.org.json.JSONObject;
import com.techventus.server.voice.Voice;
import com.techventus.server.voice.datatypes.AllSettings;
import com.techventus.server.voice.datatypes.DisabledForwardingId;
import com.techventus.server.voice.datatypes.Group;
import com.techventus.server.voice.datatypes.Phone;
import com.techventus.server.voice.datatypes.Greeting;
import com.techventus.server.voice.exception.CaptchaRequiredException;
import com.techventus.server.voice.util.ParsingUtil;
@SuppressWarnings("deprecation")
class hello {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static String pass = null;
public static void main(String args[])
{
System.out.println("Enter Your name:");
{
try {
pass = br.readLine(); }
catch (IOException ioe) {
System.out.println("IO error trying to read input!");
System.exit(1); }
System.out.println(pass);
}
}
}
I’m using java 6 under debian sid. I’m also working from the command line. I was setting my classpath as an environment variable in my .bashrc. My jars are in directory ~/java/classes. My source is in ~/java
java $ javac -cp ./classes/* hello.java
javac: invalid flag: ./classes/json.jar
Usage: javac <options> <source files>
If I comment out the two imports from json.jar the code runs fine, so thanks all for the classpath tips.
Fixed using -cp “./classes/*” worked.
Are you using any IDE or compiling the program at command line? In any case, setting the classpath to the directory containing the JAR files doesn’t work. You have to make sure your classpath lists all the JAR files separately. E.g.
If you are using Java 6, you can use classpath wildcards to resolve the same.
Related thread: How to use a wildcard in the classpath to add multiple jars?