Java's errors fall into two groups: ones from the compiler or build tool (before your code runs) and ones from the JVM (while it runs). Knowing which group you're in halves the search. Here are the common ones, fix first.
Before it runs
error: cannot find symbol
The compiler doesn't know a name. In order of likelihood: a typo or wrong case ( string vs String ), a missing import , a variable used outside its scope, or a dependency missing from pom.xml / build.gradle . The symbol: and location: lines tell you exactly which name and where.
incompatible types: possible lossy conversion from double to int
Java won't silently narrow numbers. Cast explicitly, and decide how to round:
int n = ( int ) Math . round ( x ) ;
Enter fullscreen mode
Exit fullscreen mode
error: release version 21 not supported
Your build targets a newer Java than the JDK running it. Check java -version and mvn -v / ./gradlew -version : build tools often use a different JDK than your shell, via JAVA_HOME or an IDE setting.…