我试图利用一个Java API的谷歌语音(点击此处下载:http://code.google.com/p/google-voice-java/),谷歌语音Java的1.6.jar和json.jar导入Java类
我的程序没有找到.jar文件进行导入。我确定我的类路径指向包含jar文件的目录。
我的代码下面不使用任何GV类,我只是试图导入它们。我究竟做错了什么?标准的java类导入正常。
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);
}
}
}
我在debian sid下使用了java 6。我也在从命令行工作。我在我的.bashrc中将我的classpath设置为一个环境变量。我的罐子在〜/ java/classes目录下。我的源代码在〜/ JAVA
java $ javac -cp ./classes/* hello.java
javac: invalid flag: ./classes/json.jar
Usage: javac <options> <source files>
如果我注释掉json.jar代码运行正常两个进口,所以感谢所有的类路径的提示。
使用-cp“./classes/*”固定工作。
请说明你是如何确定libs在类路径上的。有很多陷阱... – 2010-08-15 15:42:19
“我的程序没有找到导入的jar文件”。你的意思是你的*编译器*不是?你在使用哪种IDE /编译器?你如何告诉你的IDE /编译器关于罐子? – meriton 2010-08-15 15:45:22