-1

I am trying to compile a file, but its fails because of the Imports.


import org.asteriskjava.fastagi.AgiServer;
import org.asteriskjava.fastagi.MappingStrategy;
import org.asteriskjava.fastagi.ClassNameMappingStrategy;
import org.asteriskjava.fastagi.DefaultAgiServer;
import org.asteriskjava.fastagi.AgiServerThread;
import org.apache.log4j.Logger;

public class AgiServidor
{
    private static final Logger log;
    private AgiServerThread agiServerThread;
    private DefaultAgiServer agiServer;
    
   static {
        log = Logger.getLogger((Class)AgiServidor.class);
    }
    
   public void start() throws Exception {
        try {
            final ClassNameMappingStrategy cnms = new ClassNameMappingStrategy(false);
            (this.agiServer = new DefaultAgiServer((MappingStrategy)cnms)).setPoolSize(100);
            this.agiServer.setMaximumPoolSize(1800);
            final AgiServerThread agiServerThread = new AgiServerThread((AgiServer)this.agiServer);
            agiServerThread.setDaemon(false);
            agiServerThread.startup();
        }
        catch (Exception ex) {
            AgiServidor.log.error((Object)"Startup failed in MBean AgiMBean -- attempting to continue", (Throwable)ex);
        }
    }
    
   public void stop() throws Exception {
        if (this.agiServerThread != null && this != null) {
            this.agiServer.shutdown();
        }
    }
}

I investigated and I must use the library "Asterik-Java" I downloaded it but I don't know where to put it, I use the path to the downloads folder and followed the path to the file.

javac -cp C:\Users\Juan\Downloads\asterisk-java-2.0.3.jar C:\Users\Juan\Desktop\dbd\AgiServidor.java

this is the error that i got

C:\Users\Juan>javac -cp C:\Users\Juan\Downloads\asterisk-java-2.0.3.jar C:\Users\Juan\Desktop\dbd\AgiServidor.java
C:\Users\Juan\Desktop\dbd\AgiServidor.java:12: error: package org.apache.log4j does not exist
import org.apache.log4j.Logger;
                       ^
C:\Users\Juan\Desktop\dbd\AgiServidor.java:16: error: cannot find symbol
    private static final Logger log;
                         ^
  symbol:   class Logger
  location: class AgiServidor
C:\Users\Juan\Desktop\dbd\AgiServidor.java:21: error: cannot find symbol
        log = Logger.getLogger((Class)AgiServidor.class);
              ^
  symbol:   variable Logger
  location: class AgiServidor
3 errors

looks like i need another library, is it normal? what i am doing bad.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Drk-J
  • 1
  • 1

1 Answers1

0

Other than the asteriskjava library, you're also using the apache log4j library. If you include that jar file in your javac command, that should fix it. See this answer for more details and other ways to include jar files.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 01 '22 at 02:16