0
\$\begingroup\$

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)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 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.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$
6
  • \$\begingroup\$ 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 \$\endgroup\$
    – Pale_Gray
    Jul 20 at 17:46
  • \$\begingroup\$ @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. \$\endgroup\$
    – Sciborg
    Jul 20 at 19:17
  • \$\begingroup\$ here's the .jar file and components \$\endgroup\$
    – Pale_Gray
    Jul 20 at 19:57
  • \$\begingroup\$ imgur.com/a/cjVdTN9 \$\endgroup\$
    – Pale_Gray
    Jul 20 at 19:59
  • \$\begingroup\$ 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 \$\endgroup\$
    – Pale_Gray
    Jul 20 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.