(SOLVED) LWJGL3: ERROR: Context class is missing!

Hi,

I’m beginning (and start learning) with jMonkeyEngine and got issue referenced here: TestCanvas crashes with LWJGL3 · Issue #1192 · jMonkeyEngine/jmonkeyengine · GitHub

SEVERE JmeDesktopSystem 10:35:35 AM CRITICAL ERROR: Context class is missing!
Make sure jme3_lwjgl-ogl is on the classpath.
java.lang.ClassNotFoundException: com.jme3.system.lwjgl.LwjglCanvas

In the discussion, Scrappers-glitch says:
“Just use lwjgl3 native window GLFW, or lwjgl-2 if you are using swing/AWT and want to utilize jme3 app within a swing application.”

I don’t know what to do, how I can use GLFW. I’m looking for help in the officiel (or unofficial) documentation but I can’t found anything.

For example, how I can run the sample game (cf: jMonkeyEngine | Quick Start) with GLFW ?

Thanks for your help

Just replace the library jme3-lwjgl with jme3-lwjgl3 in your project to use LWJGL 3 instead of 2. How to do this depends entirely how your project is build. With ANT, Gradle or Maven?

LWJGL 2 works with Swing and canvas. 3 not so much, but it leverages GLFW if that is your cup of tea.

I’m using Maven, this is my dependecies in pom.xml

  <dependencies>
  	<dependency>
  		<groupId>org.jmonkeyengine</groupId>
  		<artifactId>jme3-core</artifactId>
  		<version>3.5.2-stable</version>
  		<type>pom.sha512</type>
  	</dependency>
  	<dependency>
  		<groupId>org.jmonkeyengine</groupId>
  		<artifactId>jme3-desktop</artifactId>
  		<version>3.5.2-stable</version>
  		<type>pom.sha512</type>
  	</dependency>
  	<dependency>
  		<groupId>org.jmonkeyengine</groupId>
  		<artifactId>jme3-lwjgl3</artifactId>
  		<version>3.5.2-stable</version>
  		<type>pom.sha512</type>
  	</dependency>
  </dependencies>

Then doing mvn install, run, and still get this issue :frowning:

I’m running the sample code found in Quick Start:

public class Main extends SimpleApplication {
 
    public static void main(String[] args) {
 
        Main app = new Main();
 
        AppSettings settings = new AppSettings(true);
        settings.setTitle("My Awesome Game");
        app.setSettings(settings);
 
        app.start();
 
    }
 
    @Override
    public void simpleInitApp() {
 
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);
 
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        geom.setMaterial(mat);
 
        rootNode.attachChild(geom);
 
    }
 
    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }
 
}

Looks like you are using LWJGL 3. So the java.lang.ClassNotFoundException: com.jme3.system.lwjgl.LwjglCanvas you will still get.

But this code example you gave… Are you sure you are getting the exact error you gave in the first post from this code? I don’t see how that would happen…

I’m sorry, you’re right, it’s not exactly the same. This is the complete error I have:

INFOS: Running on jMonkeyEngine 3.5.2-stable
 * Branch: HEAD
 * Git Hash: 8ab3d24
 * Build Date: 2022-04-21
juin 20, 2022 2:27:12 PM com.jme3.system.JmeDesktopSystem newContextLwjgl
GRAVE: CRITICAL ERROR: Context class is missing!
Make sure jme3_lwjgl-ogl is on the classpath.
java.lang.ClassNotFoundException: com.jme3.system.lwjgl.LwjglDisplay
	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:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:375)
	at com.jme3.system.JmeDesktopSystem.newContextLwjgl(JmeDesktopSystem.java:202)
	at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:275)
	at com.jme3.system.JmeSystem.newContext(JmeSystem.java:174)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:488)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:442)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:126)
	at com.elua.Main.main(Main.java:20)

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.jme3.system.JmeContext.setSettings(com.jme3.system.AppSettings)" because "ctx" is null
	at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:276)
	at com.jme3.system.JmeSystem.newContext(JmeSystem.java:174)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:488)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:442)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:126)
	at com.elua.Main.main(Main.java:20)

Hmm, something is off. That class (com.jme3.system.lwjgl.LwjglDisplay) definitely should be in jme3-lwjgl3 library. Maybe it is some Maven issue now.

Yes, seems to be Maven issue.

As you can see below, I have jm3-lwjgl3 in my pom.xml but not in Maven Dependencies on the left sidebar. Looking into it.

May be deleting the maven cache and resyncing will solve your problem, as the lwjgl-3 dependencies are already there…so may be problem with network during the downloading or something.

can you try without the <type>pom.sha512</type>?

I never use that.

That’s the tricks !

I also never use before, but it has been added automatically by my IDE… I removed it and it’s now working.

Thanks all

3 Likes
<!-- https://mvnrepository.com/artifact/org.jmonkeyengine/jme3-lwjgl -->
<dependency>
    <groupId>org.jmonkeyengine</groupId>
    <artifactId>jme3-lwjgl</artifactId>
    <version>3.5.2-stable</version>
</dependency>

It is not

<artifactId>jme3-lwjgl3</artifactId>
1 Like

OP wants to use LWJGL 3, jme3-lwjgl3 is correct then. jme3-lwjgl points to LWJGL 2.

And opinion-wise, maybe better at this point to start with LWJGL 3. It is the future, whether you want it or not. LWJGL 2 is very old and not developed anymore.

1 Like