java.lang.NoClassDefFoundError:无法初始化类com.google.api.client.util.Data [英] java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.util.Data
问题描述
编程时出现错误:
"java.lang.NoClassDefFoundError: Could not initialize class com.google.api.client.util.Data"
如何解决?
推荐答案
方式解决java.lang.NoClassDefFoundError的问题是: - 点击链接。
The ways to resolve the java.lang.NoClassDefFoundError are :- Follow the link.
当Java虚拟机不是
能够在
编译时在运行时找到特定的类时,Java中出现NoClassDefFoundError 。例如,如果我们有一个来自类的方法调用或
访问类的任何静态成员,并且该类在运行时没有
,则JVM将抛出NoClassDefFoundError。这是
很重要,要理解这与
ClassNotFoundException不同,后者在尝试仅在
运行时加载类时出现,而名称是在运行时提供的,而不是在编译
时间。许多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.
简而言之,如果在
编译时出现类但在java类路径中不可用,则会出现NoClassDefFoundError运行。
通常,当你得到
时,你会在日志中看到以下行.NoClassDefFoundError:
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:
如何解决java.lang 。 NoClassDefFoundError
:
How to resolve java.lang.NoClassDefFoundError
:
- Java Classpath中没有类。
- 您可能正在使用jar命令运行程序,并且未在清单文件的ClassPath属性中定义类。
- 任何启动脚本都会覆盖Classpath环境变量。
- 因为NoClassDefFoundError是java.lang.LinkageError的子类,所以如果其中一个依赖项(如本机库)可能不可用,也会出现这种情况。
- 检查日志文件中的java.lang.ExceptionInInitializerError。由于静态初始化失败而导致的NoClassDefFoundError非常常见。
- 如果您在J2EE环境中工作,那么多个类加载器中的Class的可见性也会导致java.lang.NoClassDefFoundError,请参阅示例和场景部分详细讨论。
- Class is not available in Java Classpath.
- You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.
- Any start-up script is overriding Classpath environment variable.
- 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.
- Check for java.lang.ExceptionInInitializerError in your log file. NoClassDefFoundError due to failure of static initialization is quite common.
- 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.
这篇关于java.lang.NoClassDefFoundError:无法初始化类com.google.api.client.util.Data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!