LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.84k stars 642 forks source link

Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException #786

Closed manuthebyte closed 2 years ago

manuthebyte commented 2 years ago

Version

3.3.1

Platform

macOS arm64

JDK

Zulu OpenJDK 1.8

Module

LWJGL Core, OpenGL

Bug description

Hi there!

I want to make a minecraft mod with forge, but when I try to start the game, it throws me back the error Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException

My build.gradle:

buildscript {
    repositories {
        maven { url "https://maven.minecraftforge.net" }
    }
    dependencies {
        classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
    }
}

plugins {
    id "java"
    id "com.github.johnrengelman.shadow" version "2.0.4"
}

apply plugin: "net.minecraftforge.gradle.forge"

version = "0.1"
group = "test.test" 
archivesBaseName = "test" 

sourceCompatibility = targetCompatibility = 1.8 
compileJava.options.encoding = "UTF-8"

project.ext.lwjglVersion = "3.3.1"
project.ext.lwjglNatives = "natives-macos-arm64"

minecraft {
    version = "1.8.9-11.15.1.2318-1.8.9"
    runDir = "run"
    mappings = "stable_22" 
    makeObfSourceJar = false 
}

configurations {
    shade
    compile.extendsFrom(shade)
}

configurations.all {
    exclude group: "org.lwjgl.lwjgl", module: "lwjgl"
    exclude group: "org.lwjgl.lwjgl", module: "lwjgl_util"
    exclude group: "org.lwjgl.lwjgl-platform", module: "natives-linux"
    exclude group: "org.lwjgl.lwjgl-platform", module: "natives-osx"
    exclude group: "org.lwjgl.lwjgl-platform", module: "natives-windows"
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: "org.lwjgl", name: "lwjgl", version: "$lwjglVersion", classifier: "${project.ext.lwjglNatives}"
    compile group: "org.lwjgl", name: "lwjgl-opengl", version: "$lwjglVersion", classifier: "${project.ext.lwjglNatives}"
}

processResources {
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    from(sourceSets.main.resources.srcDirs) {
        include "mcmod.info"

        expand "version":project.version, "mcversion":project.minecraft.version
    }

    from(sourceSets.main.resources.srcDirs) {
        exclude "mcmod.info"
    }
}

shadowJar {
    configurations = [project.configurations.shade]
    duplicatesStrategy DuplicatesStrategy.EXCLUDE 
    classifier "" 
}

reobf {
    shadowJar {}
}

Stacktrace or crash log output

[20:08:59] [main/ERROR]: Unable to launch
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
        at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
        at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
        at net.minecraft.client.main.Main.main(SourceFile:41) ~[Main.class:?]
        ... 12 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_342]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_342]
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:106) ~[launchwrapper-1.12.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_342]
Exception in thread "main"      at net.minecraft.client.main.Main.main(SourceFile:41) ~[Main.class:?]
        ... 12 more
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.reflect.InvocationTargetException
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at java.lang.reflect.Method.invoke(Method.java:498)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at GradleStart.main(GradleStart.java:26)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:30)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.Runtime.exit(Runtime.java:108)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.System.exit(System.java:973)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraft.launchwrapper.Launch.launch(Launch.java:138)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[20:08:59] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         ... 6 more
manuthebyte commented 2 years ago

Ok I changed the dependencies to that:

dependencies {
    compile group: "org.lwjgl", name: "lwjgl", version: "$lwjglVersion"
    compile group: "org.lwjgl", name: "lwjgl", version: "$lwjglVersion", classifier: "${project.ext.lwjglNatives}"
    compile group: "org.lwjgl", name: "lwjgl-opengl", version: "$lwjglVersion"
    compile group: "org.lwjgl", name: "lwjgl-opengl", version: "$lwjglVersion", classifier: "${project.ext.lwjglNatives}"
}

But now I am getting this error:

[20:23:09] [main/ERROR]: Unable to launch
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
        at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
        at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_342]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_342]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_342]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_342]
        at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
        at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/opengl/OpenGLException
        at net.minecraft.client.main.Main.main(SourceFile:41) ~[Main.class:?]
        ... 12 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.OpenGLException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_342]
Exception in thread "main"      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_342]
        at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:106) ~[launchwrapper-1.12.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_342]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_342]
        at net.minecraft.client.main.Main.main(SourceFile:41) ~[Main.class:?]
        ... 12 more
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.reflect.InvocationTargetException
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at java.lang.reflect.Method.invoke(Method.java:498)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1052]:         at GradleStart.main(GradleStart.java:26)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:30)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.SecurityManager.checkExit(SecurityManager.java:761)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.Runtime.exit(Runtime.java:108)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at java.lang.System.exit(System.java:973)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraft.launchwrapper.Launch.launch(Launch.java:138)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[20:23:09] [main/INFO]: [java.lang.ThreadGroup:uncaughtException:1061]:         ... 6 more
Spasi commented 2 years ago

The missing exception classes are from LWJGL 2, they do not exist in LWJGL 3.

manuthebyte commented 2 years ago

Yeah, the problem was that Minecraft 1.8.9 is delivering LWJGL2.9.2 and the native macOS ARM support is only above LWJGL3.3. So I can't update because it's calling old classes.

I fixed it now and have created a repo for it, for anyone that has the same problem: forge-applesilicon-fix-1.8.9