Java error: Found interface … but class was expected

后端 未结 5 2078
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 00:55

I am getting a strange runtime error from my code:

\"Found interface [SomeInterface] but class was expected\"

How can this happen? How can an i

5条回答
  •  庸人自扰
    2021-02-05 01:40

    This happens when your runtime classpath is different than your compile time classpath.

    When your application was compiled, a class (named SomeInterface in your question) existed as a class.

    When your application is running at compile time, SomeInterface exists as an interface (instead of a class.)

    This causes an IncompatibleClassChangeError to be thrown at runtime.

    This is a common occurence if you had a different version of a jar file on the compile time classpath than on the runtime classpath.

提交回复
热议问题