Unable to call JME application in Swing

I am using JME3.7.0-stable.zip

windows jdk 21, it works fine. no problem.

However in RHEL 8.10, JDK21

Failed to initialize OpenGL context
LWJGLException: Could not find GLX 1.3 config from peer info

How to resolve this problem…?

Check that you have latest and greatest display drivers. Also you might want to test LWJGL 2 or 3, depending which one you are using now.

Also what does Swing do here?

I tried on JME3.6.0-stable.zip

My Application has two java file

  1. HelloJME3.java - has SimpleApplication (JME)
  2. mySwing.java - Calls SimpleApplication through JPanel > canvas

HelloJME3

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;

/** Sample 1 - how to get started with the most simple JME 3 application.

  • Display a blue 3D cube and view from all sides by

  • moving the mouse and pressing the WASD keys. */
    public class HelloJME3 extends SimpleApplication {

    @Override
    public void simpleInitApp() {
    Box b = new Box(1, 1, 1); // create cube shape
    Geometry geom = new Geometry(“Box”, b); // create cube geometry from the shape
    Material mat = new Material(assetManager,
    “Common/MatDefs/Misc/Unshaded.j3md”); // create a simple material
    mat.setColor(“Color”, ColorRGBA.Blue); // set color of material to blue
    geom.setMaterial(mat); // set the cube’s material
    rootNode.attachChild(geom); // make the cube appear in the scene
    }
    }

mySwing

import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Canvas;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;

/*

  • Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  • Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
    */

/**
*

  • @author ADMIN
    */
    public class mySwing {

    public static void main(String args){
    HelloJME3 app = new HelloJME3();
    //app.start(); // start the game

     java.awt.EventQueue.invokeLater(new Runnable() {
    

    public void run() {
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);

     app.setSettings(settings);
     app.setPauseOnLostFocus(false);
     app.createCanvas();
     app.startCanvas(true);
     
     JmeCanvasContext context = (JmeCanvasContext) app.getContext();
     Canvas canvas = context.getCanvas();
     canvas.setSize(settings.getWidth(), settings.getHeight());
    

    // In this case the JME Canvas is not centered in the JFrame
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().add(canvas);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    }
    });

    }
    }

When i run this application in Windows enviroment (Windows 10 / JDK21), it works fine.

However when i run this application in Linux (RHEL 8.10 and JDK21)

it shows following error

run:
Feb 24, 2025 9:49:42 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-stable

  • Branch: HEAD
  • Git Hash: 53f2a49
  • Build Date: 2023-03-20
    Feb 24, 2025 9:49:43 PM com.jme3.app.LegacyApplication handleError
    SEVERE: Failed to initialize OpenGL context
    org.lwjgl.LWJGLException: Could not find GLX 1.3 config from peer info
    at org.lwjgl.opengl.LinuxPbufferPeerInfo.nInitHandle(Native Method)
    at org.lwjgl.opengl.LinuxPbufferPeerInfo.(LinuxPbufferPeerInfo.java:52)
    at org.lwjgl.opengl.LinuxDisplay.createPbuffer(LinuxDisplay.java:1348)
    at org.lwjgl.opengl.Pbuffer.createPbuffer(Pbuffer.java:235)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:220)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:191)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:167)
    at com.jme3.system.lwjgl.LwjglCanvas.makePbufferAvailable(LwjglCanvas.java:350)
    at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:490)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:120)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Feb 24, 2025 9:49:45 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main

  • Graphics Adapter: null
  • Driver Version: null
  • Scaling Factor: 1
    Feb 24, 2025 9:49:46 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio Renderer Information
  • Device: OpenAL Soft
  • Vendor: OpenAL Community
  • Renderer: OpenAL Soft
  • Version: 1.1 ALSOFT 1.15.1
  • Supported channels: 64
  • ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
  • AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
    Feb 24, 2025 9:49:46 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    WARNING: Pausing audio device not supported.
    Feb 24, 2025 9:49:46 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio effect extension version: 1.0
    Feb 24, 2025 9:49:46 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio max auxiliary sends: 4
    Feb 24, 2025 9:49:47 PM com.jme3.app.LegacyApplication handleError
    SEVERE: Uncaught exception thrown in Thread[#20,jME3 Main,6,main]
    java.lang.NullPointerException: Cannot invoke “com.jme3.renderer.Renderer.getStatistics()” because the return value of “com.jme3.app.Application.getRenderer()” is null
    at com.jme3.app.StatsAppState.loadStatsView(StatsAppState.java:190)
    at com.jme3.app.StatsAppState.initialize(StatsAppState.java:162)
    at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:332)
    at com.jme3.app.state.AppStateManager.update(AppStateManager.java:362)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:160)
    at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:231)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread “jME3 Main”

Kindly let me how to resolve this.

As to your actual problem…

The older lwjgl2 works with Swing. The newer lwjgl3 does not like Swing.

I think at some version, JME changed which one it defaults to.

2 Likes

Are you running the latest graphics drivers?

You are running on LWJGL 2 it seems, which is the default. You can try with LWJGL 3. But there is a catch, LWJGL 3 works with Swing only on jME 3.7 and onwards. With 3.6 you’ll have no luck getting it to work.

i checked on jME 3.7

Still not working… Pls check following output

run:
Feb 26, 2025 1:40:34 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.7.0-stable

  • Branch: HEAD
  • Git Hash: bc6cdf5
  • Build Date: 2024-10-21
    Feb 26, 2025 1:40:34 AM com.jme3.app.LegacyApplication handleError
    SEVERE: Failed to initialize OpenGL context
    org.lwjgl.LWJGLException: Could not find GLX 1.3 config from peer info
    at org.lwjgl.opengl.LinuxPbufferPeerInfo.nInitHandle(Native Method)
    at org.lwjgl.opengl.LinuxPbufferPeerInfo.(LinuxPbufferPeerInfo.java:52)
    at org.lwjgl.opengl.LinuxDisplay.createPbuffer(LinuxDisplay.java:1348)
    at org.lwjgl.opengl.Pbuffer.createPbuffer(Pbuffer.java:235)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:220)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:191)
    at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:167)
    at com.jme3.system.lwjgl.LwjglCanvas.makePbufferAvailable(LwjglCanvas.java:350)
    at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:490)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:120)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:224)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Feb 26, 2025 1:40:34 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main

  • Graphics Adapter: null
  • Driver Version: null
  • Scaling Factor: 1
    Feb 26, 2025 1:40:34 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio Renderer Information
  • Device: OpenAL Soft
  • Vendor: OpenAL Community
  • Renderer: OpenAL Soft
  • Version: 1.1 ALSOFT 1.15.1
  • Supported channels: 64
  • ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
  • AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
    Feb 26, 2025 1:40:34 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    WARNING: Pausing audio device not supported.
    Feb 26, 2025 1:40:34 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio effect extension version: 1.0
    Feb 26, 2025 1:40:34 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
    INFO: Audio max auxiliary sends: 4
    Feb 26, 2025 1:40:35 AM com.jme3.app.LegacyApplication handleError
    SEVERE: Uncaught exception thrown in Thread[#20,jME3 Main,6,main]
    java.lang.NullPointerException: Cannot invoke “com.jme3.renderer.Renderer.getStatistics()” because the return value of “com.jme3.app.Application.getRenderer()” is null
    at com.jme3.app.StatsAppState.loadStatsView(StatsAppState.java:190)
    at com.jme3.app.StatsAppState.initialize(StatsAppState.java:162)
    at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:332)
    at com.jme3.app.state.AppStateManager.update(AppStateManager.java:362)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:163)
    at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:231)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:245)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread “jME3 Main”

Also i checked GLX details. It shows as below

[admin@localhost ~]$ glxinfo | grep -1 version
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:

client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:

GLX_SGI_swap_control, GLX_SGI_video_sync

GLX version: 1.4
GLX extensions:

Preferred profile: core (0x1)
Max core profile version: 4.5
Max compat profile version: 4.5
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.2

Memory info (GL_ATI_meminfo):

OpenGL renderer string: llvmpipe (LLVM 17.0.2, 128 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 23.1.4
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)

OpenGL version string: 4.5 (Compatibility Profile) Mesa 23.1.4
OpenGL shading language version string: 4.50
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.1.4
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

GL_EXT_shader_framebuffer_fetch_non_coherent, GL_EXT_shader_group_vote, 
GL_EXT_shader_implicit_conversions, GL_EXT_shader_integer_mix, 
GL_EXT_shader_io_blocks, GL_EXT_tessellation_point_size, 

[admin@localhost ~]$

Kindly guide.

Phew, well, my questions and suggestions are still the same. I’m not going to offer them for the 3rd time. I assume you tried them despite seeing any evidence you did.

Hi @mahesh_jme

First I would like to ask a couple of things.

  • Are you using Waylanda?
  • Do you have XWaylanda enabled?

It’s a bit difficult to read the output you shared (I suggest you follow the standard shared by @pspeed), from what I see it can’t load or find GLX which is the GL library for X11, so you may need to check the window manager you are using (since lwjg2 has no Wayland support).

You can also try lwjgl3 as @tonihele mentioned.

1 Like

From my experience, you have to use lwjgl3 if running jme with swing on linux. This combination will not work with lwjgl2.
I had the same issue when I switched my PC from windows to linux. I ended up having to upgrade to lwjgl3 to get my application working on linux.

Also you have to use the latest stable version of jme (3.7). Older versions did not work with swing + lwjgl3

2 Likes