简体   繁体   中英

Java: NoClassDefFoundError in Eclipse while trying to use external .jar libraries

I've done searches and they haven't been any help for my problem, so here it goes.

I'm attempting to implement the Slick java library (http://slick.cokeandcode.com/) in eclipse, and I just have to add two .jar files into my buildpath.

I had gone through all of the steps in Eclipse to add two external JARs into Eclipse (my JARS show up in my "referenced libraries" section of my file system, and my short little test program compiles correctly.

My program immediately fails at runtime with this message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException at GameTest.main(GameTest.java:29)

I have checked my jars multiple times and yes, org.lwjgl.LWJGLException is contained within one of the jars in my build path. I have two libraries: slick.jar, and lwjgl.jar. LWJGLException is contained within lwjgl.jar, but line 29 invokes a class that is in slick.jar.

I am extremely confused, what else is going wrong? Both of my JARs are in my build path, what else can I do?

Thanks in advance.

You need to setup the native component of LWJGL.

have you done this ?

This is done by clicking the little arrow next to the lwjgl.jar(in the window where you have added the external jar) file to show the drop down list. Double click 'Native library location' and select the folder that contains the native files for your operating system and clicking OK. These are located in the natives folder include in the LWJGL download bundle (eg On Windows you'd point to the natives\\windows folder which contains the *.dll files, On Mac you'd point to the natives/macosx folder and on Linux you'd point to the natives/linux folder).

Check this for better understanding

Setting Up LWJGL with Eclipse

Some IDE include libraries in development, but most likely you will need to package your jars with your project or add them to the globally referenced directory that contains the libraries used by your server.

Even if this does not resolve your issue it may help future visitors who land up here with similar issues.

Remember that development and production environments differ.

尝试重建项目: Project > Clean

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM