Reputation: 11
I am relatively new to Java, and I have made a script which uses the LWJGL 3. The program runs perfectly fine within the Eclipse IDE but when I attempt to export it as a runnable Jar file (I checked package required libraries field) and then attempt to run it through windows command line I get the error message as follows:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
at renderEngine.TestEngine.main(TestEngine.java:18)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more
I am assuming this is an issue caused by a lack of access to the libraries I imported, but after searching the web for a while I could not find a single proper guided answer to solving the question. Most of the time it was someone asking the question and then just stating they solved it themselves or someone else explaining the issue but not actually assisting with it. I am hoping someone can assist me with a guided explanation of how to fix this issue, and also if it could be explained as to avoid future issues.
If any more information is needed to assist with the issue I will be happy to provide it.
UPDATE: It seems that the issue is with GLFW and not the library as a whole. As re-reading the error, the only thing that cannot be found or loaded is GLFW when I am also using other imports from the same library such as OpenGL. Also, the line it specifies is the line in which I call a function from GLFW and not when I import the package, don't know if that is because errors don't get called when imports are unsuccessful or if there is another issue possibly within the package itself. I don't know if I am correct just trying to help by providing more information.
Thanks, Oliver :)
Upvotes: 1
Views: 344
Reputation: 8357
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
Upvotes: 1