Mixed Kotlin + Java with Maven, unresolved reference

The compilation fails because your Java class is not in a directory that matches its package statement. While Kotlin allows you to put classes in any directories regardless of the package they're in, Java requires you to put each file in a package that corresponds to its directory. This requirement applies to mixed-language projects as well.

To fix the error, move JavaFoo.java to src/main/java/com/example/kotlindemo.