0
\$\begingroup\$

I have not used Java in a while and thought I might try LWJGL with OpenGL and GLFW. I am using Apache Maven as a Build System. It lets me compile the program, but when I run it, it says:

Exception in thread "main" java.lang.NoClassDefFoundError: org.lwjgl/glfw/GLFW at com.OpenGLTest.app.Main.main(Main.java:25) Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java.641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 1 more 

My code is:

// Main.java package com.OpenGLTest.app; import org.lwjgl.*; import org.lwjgl.glfw.*; import org.lwjgl.opengl.*; import org.lwjgl.system.*; import java.nio.*; import static org.lwjgl.glfw.Callbacks.*; import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.system.MemoryUtil.*; public class Main { private static long window; private static final int WIDTH = 800; private static final int HEIGHT = 600; private static final String TITLE = "OpenGL Window"; public static void main(String[] args) { // CHECK if (!glfwInit()) { System.err.println("ERROR: GLFW IS NOT INSTALLED"); System.exit(-1); } glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_VISIBLE, 0); glfwWindowHint(GLFW_RESIZABLE, 0); window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL); if (window == NULL) { System.err.println("ERROR: FAILED TO CREATE GLFW WINDOW"); } glfwMakeContextCurrent(window); glfwShowWindow(window); } } 

My LWJGL version is 3.3.3 My JRE is 17

I am sorry if the answer is obvious. Somehow the only kinda answer I found on the internet is http://forum.lwjgl.org/index.php?topic=6994.0:

https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java

How to solve this entirely depends on how you invoke the java command, whether you use an >IDE and which one you use, whether you use the Java 9+ Module System or the classpath and >whether you use a Java build system (like Maven, Gradle, Ant+Ivy).

\$\endgroup\$
2
  • \$\begingroup\$ This is not gamedev specific. This question should be asked on stackoverflow.com. My advice to you is to find a Java project that uses GLFW successfully, and adapt that for your needs. \$\endgroup\$ Commented Jul 6, 2024 at 0:22
  • \$\begingroup\$ Since you have problem with dependencies adding pom.xml to this question would help a lot. \$\endgroup\$ Commented Jul 9, 2024 at 5:48

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.