Why do I get NoClassDefFoundError: java/awt/Desktop?

旧巷老猫 提交于 2019-12-02 09:50:07

Doc on NoClassDefFoundError

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

You do have some incorrect classloading happening. Mostly due to wrong class loader chaining.

NoClassDefFoundError can only be caused by a classpath problem.

Because Desktop is part of jre, make sure that your classpath contains a reference to the jre library.

In Eclipse, you can go to run configurations --> Classpath and check there

UPDATE:

As Andrew suggested, you can also check you have at least java 1.6

java.awt.Desktop has been introduced in Java 6. Chances are high you're running your code on different JRE versions.

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