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

拈花ヽ惹草 提交于 2019-11-26 17:22:11

问题


When I programming, an error occured:

"java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.util.Data"

How to resolve it?


回答1:


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 any static member of a Class and that class is not available during run-time then JVM will throw NoClassDefFoundError. It’s important to understand that this is different than ClassNotFoundException which comes while trying to load a class at run-time only and name was provided during runtime not on compile time. Many Java developer mingle this two Error and gets confused.

In short NoClassDefFoundError will come if a class was present during compile time but not available in java classpath during runtime. Normally you will see below line in log when you get NoClassDefFoundError:

How to resolve java.lang.NoClassDefFoundError:

  1. Class is not available in Java Classpath.
  2. You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.
  3. Any start-up script is overriding Classpath environment variable.
  4. Because NoClassDefFoundError is a sub class of java.lang.LinkageError it can also come if one of it dependency like native library may not available.
  5. Check for java.lang.ExceptionInInitializerError in your log file. NoClassDefFoundError due to failure of static initialization is quite common.
  6. If you are working in J2EE environment than visibility of Class among multiple Classloaders can also cause java.lang.NoClassDefFoundError, see examples and scenario section for detailed discussion.



回答2:


You or some code you have imported into your project seems to refer to the Google Data Client API, but you didn't import the necessary .jar file into your projects dependencies.

Try copying this jar into your project: https://code.google.com/p/gdata-java-client/downloads/list?hl=de

Maybe the setup instructions here also are interesting for you: https://developers.google.com/gdata/articles/java_client_lib?hl=de#gdata



来源:https://stackoverflow.com/questions/25011108/java-lang-noclassdeffounderror-could-not-initialize-class-com-google-api-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!