当前位置: 代码迷 >> J2SE >> 使用 java 写 asterisk AGI 编译 出错,该如何解决
  详细解决方案

使用 java 写 asterisk AGI 编译 出错,该如何解决

热度:817   发布时间:2016-04-24 01:12:34.0
使用 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.
  相关解决方案