Troubleshoot NoClassDefFoundError in Java

This is due to your classpath, which will default to the current directory. When you run java Main from /home/user/program it finds the class in the current directory (since the package seems to be unset, meaning it is the default). Hence, it finds the class in /home/user/program/Main.class. Running java /home/user/program/Main from /home tries to find … Read more

java.lang.NoClassDefFoundError when using MongoDB driver

You have java.lang.NoClassDefFoundError – that means your class is missed during runtime (not during build/compile time). So you should open your “Run Configurations” dialog for the project (project context menu -> “Run As” -> “Run Configurations…”) and make sure you have bson-xxx.jar, mongodb-driver-xxx.jar, and mongodb-driver-core-xxx.jar somehow listed in Classpath tab. And yes, like Xavier Bouclet … Read more

java.lang.NoClassDefFoundError: android/graphics/drawable/Icon

Update The issue is fixed in support library 27.0.0. If you update don’t forget to change compileSdkVersion 27 as well. What is happening? Samsung devices with Android 4.4 crash like this when classes extending View define methods which return or take parameters of types that are not on classpath. Starting with support library version 25.4.0 … Read more

java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.util.Data [closed]

The ways to resolve the java.lang.NoClassDefFoundError are :- Follow the link. What is reason of NoClassDefFoundError in Java? NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during compile time. For example if we have a method call from a class or accessing … Read more

Why NoClassDefFoundError caused by static field initialization failure?

The answer to such questions is usually buried somewhere in the specs… (ยง12.4.2) What happens when classes are initialized: Steps 1-4 are somewhat unrelated to this question. Step 5 here is what triggers the exception: 5. If the Class object is in an erroneous state, then initialization is not possible. Release the lock on the … Read more

java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap error using GeckoDriver Firefox through Selenium in Java

This error message… Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap at org.openqa.selenium.firefox.FirefoxDriver …implies that the file com/google/common/collect/ImmutableMap might be corrupted or there is some incompatibility between the version of the binaries you are using specifically with the guava version / dependency (maven). You need to take care of a couple of things as follows: In the … Read more