# Building an LWJGL jar file - java.lang.NoClassDefFoundError

EDIT: Recently got it working by making a batch file that does this:

set /p CP=<cp.txt
java -cp %CP%;testing.jar me.pale.main.Main


and cp.txt is this

C:\Users\*\Desktop\LWJGL293\lwjgl-2.9.3\jar\lwjgl.jar;C:\Users\*\Desktop\LWJGL293\lwjgl-2.9.3\jar\lwjgl_util.jar;C:\Users\*\Desktop\LWJGL293\lwjgl-2.9.3\jar\jinput.jar;C:\Users\*\Desktop\LWJGL293\slick-util.jar


Recently, I've been in my head about LWJGL and creating games, and have made a simple test thingy. I tried to build the jar using eclipse, but when I run the jar file, it errors out. When I use Command Prompt, this is the output:

D:\>java -jar testing.jar
Picked up _JAVA_OPTIONS: -Xmx8192M
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
... 7 more


My native folder is correct, I've checked it.

The project runs perfectly fine in the IDE

Here's what is in my build path:

jinput.jar
lwjgl_util.jar
lwgl.jar > NativeLibLoc: [Native Dir]
slick-util.jar
jre system library [SE-1.8]


I don't know what the problem is, but thank you for anyone's help.

According to this StackOverflow answer: https://stackoverflow.com/questions/29334257/java-lang-noclassdeffounderror-org-lwjgl-lwjglexception

I figured it out so I will post it in case anyone else having the same problem stumbles upon this page. I had to use an older version of lwjgl.jar, version 2.9.3 worked from the old lwjgl website http://legacy.lwjgl.org/ .

There is also this StackOverflow answer: https://stackoverflow.com/questions/20044200/java-lang-noclassdeffounderror-with-lwjgl

Try to run it like this:

java -cp lib\win32\lwjgl.jar;Valor.jar Main

The problem is that the -cp option is ignored when -jar is used.

Alternatively, you could extend the class path by adding a Class-Path: entry in your manifest and putting lib\win32\lwjgl.jar in it.

Class-Path: lib\win32\lwjgl.jar

• I tried that and it would error out saying that it could not find main class Main or could not find main class [title].jar Jul 20, 2021 at 17:46
• @Pale_Gray If it can't find the main class, it might be a directory problem (or just not having a main class, is your main class definitely in the class path?). It's hard to diagnose further without knowing your project setup. Jul 20, 2021 at 19:17
• here's the .jar file and components Jul 20, 2021 at 19:57
• imgur.com/a/cjVdTN9 Jul 20, 2021 at 19:59
• when I use java -cp C:\Users\*****\Desktop\LWJGL293\lwjgl-2.9.3\jar\lwjgl.jar;testing.jar me.pale.main.Main, it says no lwjgl64 in java.library.path Jul 20, 2021 at 20:03