我在编译这些 java 文件时遇到问题。我有一个类 MeterMovementService.java 和一个接口 MeterMovementServiceMBean.java 。该类正在实现这个接口。我首先编译了接口。类和接口都位于同一个包中。但是当我尝试编译该类时,它会给出错误:
MeterMovementService.java:2: error: cannot find symbol
public class MeterMovementService implements MeterMovementServiceMBean
^
symbol: class MeterMovementServiceMBean
1 error
这是 MeterMovementService.java 类的代码
我的类没有依赖。它只是实现了接口。
public class MeterMovementService implements MeterMovementServiceMBean {
private String message = "Sorry no message today";
public String getMessage(){
return message;
}
public void setMessage(String message){
this.message = message;
}
public void printMessage(){
System.out.println(message);
}
public void start() throws Exception{
System.out.println(">>>>Starting with message=" + message);
}
public void stop() throws Exception{
System.out.println(">>>>Stopping with message=" + message);
}
}