NoClassDefFoundError by switching to another project

╄→гoц情女王★ 提交于 2019-12-13 03:00:53

问题


I have read a lot of answers here to NoClassDefFoundError, but somehow I could not find one that solves my problem. Maybe I have not enough experience to transform it to my problem.

Anyway, I have a project (imported over git) with a package and lots of helpful functions. There is as well a package with some demos, they work completely fine.

If I now copy one of those demos in my own project, I get the error

Exception in thread "main" java.lang.NoClassDefFoundError: org/jfree/data/xy/XYDataset at net.[...]

I think there must be a simple solution, since it runs in the other project.

Thank you for taking your time.


回答1:


NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available at 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.

  • The class is not available in Java Classpath.
  • You might be running your program using jar command and the class was not defined in manifest file's ClassPath attribute.
  • Any start-up script is overriding Classpath environment variable.
  • Because NoClassDefFoundError is a subclass of java.lang.LinkageError it can also come if one of its dependency like native library may not available.
  • If you are working in J2EE environment than the visibility of Class among multiple Classloader can also cause java.lang.NoClassDefFoundError, see examples and scenario section for detailed discussion.


来源:https://stackoverflow.com/questions/56810860/noclassdeffounderror-by-switching-to-another-project

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