日期:2014-05-20  浏览次数:20751 次

使用 java 写 asterisk AGI 编译 出错
我按照教程使用 javac -cp asterisk-java.jar HelloAGIScript.java 进行AGI的java 程序进行编译,但出现下面出错:

HelloAGIScript.java:1: package net.sf.asterisk.fastagi does not exist
import net.sf.asterisk.fastagi.AGIChannel;
  ^
HelloAGIScript.java:2: package net.sf.asterisk.fastagi does not exist
import net.sf.asterisk.fastagi.AGIException;
  ^
HelloAGIScript.java:3: package net.sf.asterisk.fastagi does not exist
import net.sf.asterisk.fastagi.AGIRequest;
  ^
HelloAGIScript.java:4: package net.sf.asterisk.fastagi does not exist
import net.sf.asterisk.fastagi.AbstractAGIScript;
  ^
HelloAGIScript.java:6: cannot find symbol
symbol: class AbstractAGIScript
public class HelloAGIScript extends AbstractAGIScript
  ^
HelloAGIScript.java:8: cannot find symbol
symbol : class AGIRequest
location: class HelloAGIScript
public void service(AGIRequest request, AGIChannel channel)
^
HelloAGIScript.java:8: cannot find symbol
symbol : class AGIChannel
location: class HelloAGIScript
public void service(AGIRequest request, AGIChannel channel)
^
HelloAGIScript.java:9: cannot find symbol
symbol : class AGIException
location: class HelloAGIScript
throws AGIException
^
8 errors

信 10:19:22
HelloAGIScript.java 代码 如下:
import net.sf.asterisk.fastagi.AGIChannel;
import net.sf.asterisk.fastagi.AGIException;
import net.sf.asterisk.fastagi.AGIRequest;
import net.sf.asterisk.fastagi.AbstractAGIScript;

public class HelloAGIScript extends AbstractAGIScript
{
  public void service(AGIRequest request, AGIChannel channel)
  throws AGIException
  {
  // Answer the channel...
  answer(channel);

  // ...say hello...
  streamFile(channel, "welcome");

  // ...and hangup.
  hangup(channel);
  }
}

------解决方案--------------------
or put asterisk-java.jar and HelloAGIScript.java in /astjava, cd /astjava and run javac
Note, jar file name is asterisk-java-3.0.jar that is different with sample.