Java exceptions are split into checked exceptions (which you must handle) and unchecked RuntimeExceptions (which are programming bugs). On top of that, the JVM itself can throw Error subtypes like OutOfMemoryError that signal unrecoverable problems. Each entry below covers the most common Java exceptions with fixes you can apply immediately.

Error Codes

ErrorDescriptionFix
NullPointerExceptionDereferencing null before calling a method or accessing a fieldAdd null checks, use Optional, and apply Objects.requireNonNull() for validation
ClassNotFoundExceptionClass cannot be found at runtime — missing from classpath or build outputVerify classpath, check JAR files, confirm Maven/Gradle dependencies, and inspect classloaders
ClassCastExceptionObject cannot be cast to the specified type — invalid type conversionUse instanceof before casting, apply generics, and use safe casting patterns
OutOfMemoryErrorJVM heap space exhausted — application cannot allocate more memoryIncrease heap with -Xmx, fix memory leaks, and profile with VisualVM or MAT
StackOverflowErrorInfinite recursion or excessively deep call stackAdd a base case to recursive methods, convert to iteration, or increase -Xss stack size

Quick Debug

# Enable verbose class loading
java -verbose:class -jar myapp.jar

# Get a thread dump on a running JVM
jstack <PID>