Java Errors

Common Java errors and how to fix them.

95 errors
☕ Java
null-checkruntime-exceptionjep358

Cannot invoke "com.devinhyderabad.shop.Customer.getCity()" because the return value of "com.devinhyderabad.shop.OrderService.findCustomer(java.lang.Long)" is null

Since JDK 15 the JVM names the exact null value right in the message — learn to read the JEP 358 hint and fix the dereference instead of guessing.

☕ Java
classpathreflectionchecked-exception

ClassNotFoundException: com.devinhyderabad.pay.PaymentGateway

The JVM searched every classpath location for a class referenced by its dotted name and found nothing — usually a missing JDBC driver, a reflective load, or a fat jar that never packed the dependency.

☕ Java
linkage-errorclasspathfat-jar

NoClassDefFoundError: com/devinhyderabad/pay/PaymentGateway

The class existed at compile time but vanished from the runtime classpath — this LinkageError strikes on first real use, and its Caused by chain shows the slash-form name the loader actually wanted.

☕ Java
jvm-version-mismatchdeploymentdocker

Has been compiled by a more recent version of the Java Runtime (class file version 65.0)

Your jar was compiled by a newer JDK than the JVM running it — class file version 65.0 needs Java 21, and an older runtime refuses to link it.

☕ Java
memory-leakgarbage-collectoroom

OutOfMemoryError: Java heap space

The JVM asked the garbage collector for room and none existed — heap exhausted, and every OOM variant (Metaspace, GC overhead, native threads) has a different culprit and fix.

☕ Java
collectionsfail-fastiterator

ConcurrentModificationException

A fail-fast iterator caught a structural modification mid-walk — usually plain single-threaded code calling list.remove() inside a for-each loop.

All Java errors