zhanghong920
Programmer
Hi all,
I'm trying to read the class name from a configure file, and then create an instant of it. The related classes are:
//G:
public interface G{
public void setProperties(Properties p);
public void setDBConnect();
}
//F:
public class F extends SF implements G{
//implement setProperties(), setDBConnect(), and other overriding methods defined in the superclass SF.
}
//A:
public class A{
public static void main(..){
String className = ... //get from the configure file
Properties p = ... //build according to the configuring
Object obj = Class.forName(className).newInstance();
G obj = (G) obj;
obj.setProperties(p);
}
}
Some other unrelated lines are omitted here. The problem is: it's fine in compiling. But when I run: "java A",there's an error message as below:
Exception in thread "main" java.lang.IncompatibleClassChangeError: class abb.dlt.oai.client.F has interface abb.dlt.oai.client.G as super class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at abb.dlt.oai.client.A.main(A.java:63)
Anything I missed? Thanks a lot,
Zhanghong920
I'm trying to read the class name from a configure file, and then create an instant of it. The related classes are:
//G:
public interface G{
public void setProperties(Properties p);
public void setDBConnect();
}
//F:
public class F extends SF implements G{
//implement setProperties(), setDBConnect(), and other overriding methods defined in the superclass SF.
}
//A:
public class A{
public static void main(..){
String className = ... //get from the configure file
Properties p = ... //build according to the configuring
Object obj = Class.forName(className).newInstance();
G obj = (G) obj;
obj.setProperties(p);
}
}
Some other unrelated lines are omitted here. The problem is: it's fine in compiling. But when I run: "java A",there's an error message as below:
Exception in thread "main" java.lang.IncompatibleClassChangeError: class abb.dlt.oai.client.F has interface abb.dlt.oai.client.G as super class
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at abb.dlt.oai.client.A.main(A.java:63)
Anything I missed? Thanks a lot,
Zhanghong920