I installed LWJGL to study how opengl works and used the code from this publicly posted site.
package com.myCompany;
import .lwjgl.opengl.GL;
import .lwjgl.opengl.awt.AWTGLCanvas;
import .lwjgl.opengl.awt.GLData;
import javax.swing.*;
import java.awt.*;
import static .lwjgl.glfw.GLFW.*;
import static .lwjgl.opengl.GL45.*;
import static .lwjgl.opengl.GL.createCapabilities;
public class GLTest {
public static void main(String[] args) {
GLData data = new GLData();
AWTGLCanvas canvas = new AWTGLCanvas(data) {
@Override
public void initGL() {
glfwInit();
createCapabilities();
glClearColor(0.3f, 0.4f, 0.5f, 1);
}
@Override
public void paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
glEnd();
swapBuffers();
}
};
JFrame wnd = new JFrame();
wnd.setLayout(new BorderLayout());
wnd.setPreferredSize(new Dimension(500, 500));
wnd.setVisible(true);
wnd.pack();
wnd.transferFocus();
wnd.add(canvas);
Runnable renderLoop = new Runnable() {
@Override
public void run() {
if (!canvas.isValid()) {
GL.setCapabilities(null);
return;
}
canvas.render();
SwingUtilities.invokeLater(this);
}
};
SwingUtilities.invokeLater(renderLoop);
}
}
But it throws the following exception at canvas.render()
:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'short .lwjgl.system.windows.User32.RegisterClassEx(.lwjgl.system.windows.WNDCLASSEX)'
at .lwjgl.opengl.awt.PlatformWin32GLCanvas.createDummyWindow(PlatformWin32GLCanvas.java:134)
at .lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:154)
at .lwjgl.opengl.awt.AWTGLCanvas.beforeRender(AWTGLCanvas.java:60)
at .lwjgl.opengl.awt.AWTGLCanvas.render(AWTGLCanvas.java:101)
at com.myCompany.GLTest$2.run(GLTest.java:52)
Here is a part of the pom.xml file.
<properties>
<mavenpiler.source>23</mavenpiler.source>
<mavenpiler.target>23</mavenpiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lwjgl.version>3.3.6</lwjgl.version>
<joml.version>1.10.7</joml.version>
<lwjgl3-awt.version>0.1.8</lwjgl3-awt.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-bom</artifactId>
<version>${lwjgl.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>lwjgl-natives-linux-amd64</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-macos-x86_64</id>
<activation>
<os>
<family>mac</family>
<arch>x86_64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-macos</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows-amd64</id>
<activation>
<os>
<family>windows</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-windows</lwjgl.natives>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.joml</groupId>
<artifactId>joml</artifactId>
<version>${joml.version}</version>
</dependency>
<dependency>
<groupId>.lwjglx</groupId>
<artifactId>lwjgl3-awt</artifactId>
<version>${lwjgl3-awt.version}</version>
</dependency>
</dependencies>
It worked fine in a Linux environment with the same conditions.
The OS that is causing the problem is windows 11, and The native library is windows-amd64.
The native library for Linux OS is linux-amd64.
Am I missing something?
I installed LWJGL to study how opengl works and used the code from this publicly posted site. https://github/LWJGLX/lwjgl3-awt?tab=readme-ov-file
package com.myCompany;
import .lwjgl.opengl.GL;
import .lwjgl.opengl.awt.AWTGLCanvas;
import .lwjgl.opengl.awt.GLData;
import javax.swing.*;
import java.awt.*;
import static .lwjgl.glfw.GLFW.*;
import static .lwjgl.opengl.GL45.*;
import static .lwjgl.opengl.GL.createCapabilities;
public class GLTest {
public static void main(String[] args) {
GLData data = new GLData();
AWTGLCanvas canvas = new AWTGLCanvas(data) {
@Override
public void initGL() {
glfwInit();
createCapabilities();
glClearColor(0.3f, 0.4f, 0.5f, 1);
}
@Override
public void paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
glEnd();
swapBuffers();
}
};
JFrame wnd = new JFrame();
wnd.setLayout(new BorderLayout());
wnd.setPreferredSize(new Dimension(500, 500));
wnd.setVisible(true);
wnd.pack();
wnd.transferFocus();
wnd.add(canvas);
Runnable renderLoop = new Runnable() {
@Override
public void run() {
if (!canvas.isValid()) {
GL.setCapabilities(null);
return;
}
canvas.render();
SwingUtilities.invokeLater(this);
}
};
SwingUtilities.invokeLater(renderLoop);
}
}
But it throws the following exception at canvas.render()
:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'short .lwjgl.system.windows.User32.RegisterClassEx(.lwjgl.system.windows.WNDCLASSEX)'
at .lwjgl.opengl.awt.PlatformWin32GLCanvas.createDummyWindow(PlatformWin32GLCanvas.java:134)
at .lwjgl.opengl.awt.PlatformWin32GLCanvas.create(PlatformWin32GLCanvas.java:154)
at .lwjgl.opengl.awt.AWTGLCanvas.beforeRender(AWTGLCanvas.java:60)
at .lwjgl.opengl.awt.AWTGLCanvas.render(AWTGLCanvas.java:101)
at com.myCompany.GLTest$2.run(GLTest.java:52)
Here is a part of the pom.xml file.
<properties>
<mavenpiler.source>23</mavenpiler.source>
<mavenpiler.target>23</mavenpiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lwjgl.version>3.3.6</lwjgl.version>
<joml.version>1.10.7</joml.version>
<lwjgl3-awt.version>0.1.8</lwjgl3-awt.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-bom</artifactId>
<version>${lwjgl.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>lwjgl-natives-linux-amd64</id>
<activation>
<os>
<family>unix</family>
<name>linux</name>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-macos-x86_64</id>
<activation>
<os>
<family>mac</family>
<arch>x86_64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-macos</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows-amd64</id>
<activation>
<os>
<family>windows</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<lwjgl.natives>natives-windows</lwjgl.natives>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>.joml</groupId>
<artifactId>joml</artifactId>
<version>${joml.version}</version>
</dependency>
<dependency>
<groupId>.lwjglx</groupId>
<artifactId>lwjgl3-awt</artifactId>
<version>${lwjgl3-awt.version}</version>
</dependency>
</dependencies>
It worked fine in a Linux environment with the same conditions.
The OS that is causing the problem is windows 11, and The native library is windows-amd64.
The native library for Linux OS is linux-amd64.
Am I missing something?
Share Improve this question edited Mar 27 at 16:33 noen asked Mar 26 at 12:27 noennoen 617 bronze badges1 Answer
Reset to default 0This issue was caused by a version mismatch between the awt library 0.1.8
and the lwjgl library 3.3.6
. This issue is resolved by updating the awt library to 0.2.3
or downgrading the lwjgl library to 3.3.3
.
When updating to 3.3.6
, I found that the method was fixed, which is why this error occurs.
I was unable to download awt 0.2.3
, but rebooting my PC fixed it.