An error of type IncompatibleClassChangeError
is usually an improper compilation process.
For example:
Create the following classes:
public class Teste {
public static void main(String[] args) {
Teste2.hello();
}
}
public class Teste2 {
public static void hello() {
System.out.println("Oi");
}
}
Compile the classes like this:
javac Teste.java Teste2.java
Change the Teste2
class by removing the static
modifier:
public class Teste2 {
public void hello() {
System.out.println("Oi");
}
}
Recompile only the class Teste2
:
javac Teste2.java
Run the program:
java Teste
Here's the output:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Expected static method Teste2.hello()V
at Teste.main(Teste.java:3)
There are several other ways to generate IncompatibleClassChangeError
, but all of them are the result of mixing classes that have been altered and recompiled in ways that are incompatible with each other. The best suggestion to fix this is to delete any .class
files from your project and recompile everything from scratch.