0

Im getting Exception in thread "main" java.lang.Error: Unresolved compilation.

What am I doing wrong?

public class idsbasedagent{
    JDCaptor captor ;

    public idsbasedagent(){
        captor=new JDCaptor();
    }

    public static void main(String[] args){
        System.out.println("؟ھت¼×¥°ü");
        idsbasedagent agent=new idsbasedagent();
        agent.capturesFromDevice();
    }
}

Exception in thread "main":

java.lang.Error: Unresolved compilation problem:

The method capturesFromDevice() is undefined for the type idsbasedagent at idsbasedagent.main(idsbasedagent.java:11)

manlio
  • 18,345
  • 14
  • 76
  • 126
Mohssine
  • 21
  • 3

2 Answers2

2

The main method is calling method "capturesFromDevice" on the "agent" object of type "idsbasedagent". However , your class "idsbasedagent" doesn't have the method "capturesFromDevice()" defined in it. So you need to define that method for eg:

public class idsbasedagent{
    JDCaptor captor ;

    public idsbasedagent(){
        //...
    }

    public void captureFromDevice() {
        //implementation
    }
}

Or it could be that "captureFromDevice" is a method of JDCaptor class. In which case, you would need to call that method on the the agent's "captor" member variable like so:

agent.captor.captureFromDevice()

Sidenote: With regards to class names, the java coding convention dictates that class/interfaces should be capitalised. Have a look at this: http://www.oracle.com/technetwork/java/codeconventions-135099.html

The rest of the convention topics can be found here: http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

Hope that helps.

mmaarouf
  • 560
  • 6
  • 9
0

The Class idsbasedagent is expected to have a method 'capturesFromDevice' if you want its instances to be able to call it.

You cannot call a method which has not been defined.

public class idsbasedagent{
JDCaptor captor ;

public idsbasedagent(){
    captor=new JDCaptor();
}

public void capturesFromDevice(){
    //Method action here
}

public static void main(String[] args){
    System.out.println("؟ھت¼×¥°ü");
    idsbasedagent agent=new idsbasedagent();
    agent.capturesFromDevice();
}
}
Arun Iyer
  • 54
  • 2
  • 5