0

I have created my jar file, but when I try to run it with java -jar .\MarvelousMashup.jar I get a huge error message which does not occur when I just run the main class in IntelliJ. I used the steps from here and it was able to be created and also didn't give me any no main manifest attribute, in xxxxx.jar errors. This is the error message

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/lwjgl/system/Callback.<clinit>()V @167: invokestatic
  Reason:
    Type 'org/lwjgl/PointerBuffer' (current frame, stack[1]) is not assignable to 'org/lwjgl/system/CustomBuffer'
  Current Frame:
    bci: @167
    flags: { }
    locals: { 'org/lwjgl/system/MemoryStack', null, '[Ljava/lang/Class;', '[Ljava/lang/reflect/Method;', 'org/lwjgl/PointerBuffer' }
    stack: { '[Ljava/lang/reflect/Method;', 'org/lwjgl/PointerBuffer' }
  Bytecode:
    0x0000000: b200 3803 b800 39b6 003a c000 3bb6 003c
    0x0000010: b300 19b8 003d 4b01 4c04 bd00 3e59 03b2
    0x0000020: 003f 534d 100a bd00 4059 0312 4112 422c
    0x0000030: b600 4353 5904 1244 1242 2cb6 0043 5359
    0x0000040: 0512 4512 422c b600 4353 5906 1246 1242
    0x0000050: 2cb6 0043 5359 0712 4712 422c b600 4353
    0x0000060: 5908 1248 1242 2cb6 0043 5359 1006 1249
    0x0000070: 1242 2cb6 0043 5359 1007 124a 1242 2cb6
    0x0000080: 0043 5359 1008 124b 1242 2cb6 0043 5359
    0x0000090: 1009 124c 1242 2cb6 0043 534e 2a2d beb6
    0x00000a0: 004d 3a04 2d19 04b8 004e b800 4f58 1904
    0x00000b0: b600 50b3 001e 1904 b600 50b3 001f 1904
    0x00000c0: b600 50b3 0020 1904 b600 50b3 0021 1904
    0x00000d0: b600 50b3 0022 1904 b600 50b3 0023 1904
    0x00000e0: b600 50b3 0024 1904 b600 50b3 0026 1904
    0x00000f0: b600 50b3 0027 1904 b600 50b3 0025 2ac6
    0x0000100: 0046 2bc6 0013 2ab6 0051 a700 3b4d 2b2c
    0x0000110: b600 53a7 0032 2ab6 0051 a700 2b4d 2c4c
    0x0000120: 2cbf 3a05 2ac6 001d 2bc6 0015 2ab6 0051
    0x0000130: a700 123a 062b 1906 b600 53a7 0007 2ab6
    0x0000140: 0051 1905 bfa7 000f 4bbb 0016 5912 552a
    0x0000150: b700 56bf b800 5757 b1
  Exception Handler Table:
    bci [262, 266] => handler: 269
    bci [25, 254] => handler: 285
    bci [25, 254] => handler: 290
    bci [300, 304] => handler: 307
    bci [285, 292] => handler: 290
    bci [19, 325] => handler: 328
  Stackmap Table:
    full_frame(@269,{Object[#164],Object[#165]},{Object[#165]})
    same_frame(@278)
    same_locals_1_stack_item_frame(@285,Object[#165])
    same_locals_1_stack_item_frame(@290,Object[#165])
    full_frame(@307,{Object[#164],Object[#165],Top,Top,Top,Object[#165]},{Object[#165]})
    same_frame(@318)
    same_frame(@322)
    full_frame(@325,{},{})
    same_locals_1_stack_item_frame(@328,Object[#166])
    same_frame(@340)

        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.initializeGlfw(Lwjgl3Application.java:81)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:91)
        at com.marvelous.game.desktop.DesktopLauncher.main(DesktopLauncher.java:23)

It seems to me like some sort of LibGDX error, but I have no idea what could've caused it. I built it with all dependencies, is there any other way to build it. The project works with gradle if that helps.

task dist(type: Jar) {
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}

This is the only thing in my build.gradle for the Desktop that I could find something with a Jar. But it creates seperate ones for my Desktop and my core. The Problem is they need to be one jar. core and desktop each have a build.gradle. As does the entire project. But trying to create one there doesnt even run the task. In case it helps I will paste the code of all build.gradle.

build.gradle(project)

buildscript {


    repositories {
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        google()
    }
    dependencies {


    }
}

allprojects {
    apply plugin: "eclipse"

    version = '1.0'
    ext {
        appName = "MarvelousMashup"
        gdxVersion = '1.10.0'
        roboVMVersion = '2.3.12'
        box2DLightsVersion = '1.5'
        ashleyVersion = '1.7.3'
        aiVersion = '1.8.2'
        gdxControllersVersion = '2.1.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        google()
        gradlePluginPortal()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java-library"


    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        implementation 'com.google.code.gson:gson:2.8.7'

    }
}

project(":core") {
    apply plugin: "java-library"


    dependencies {
        api "com.badlogicgames.gdx:gdx:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
        api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
        api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        implementation 'com.google.code.gson:gson:2.8.7'
        implementation "org.java-websocket:Java-WebSocket:1.5.1"
    }
}

build.gradle(:desktop)

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../core/assets"]

project.ext.mainClassName = "com.marvelous.game.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")

task run(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
    debug = true
}

task dist(type: Jar) {
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}


dist.dependsOn classes

eclipse.project.name = appName + "-desktop"

build.gradle(:core)

sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = ["src/"]

eclipse.project.name = appName + "-core"
Biohazard
  • 37
  • 6
  • There is a gradle task to build a jar '''desktop:dist''' which you can add as a run/debug configuration, this comes with the skeleton project. You don't have to manually create. Maybe that makes this alarming error disappear, its mentioned here but that doesn't explain why it works from the IDE https://stackoverflow.com/questions/30365106/reason-for-the-exception-java-lang-verifyerror-bad-type-on-operand-stack – londonBadger Aug 29 '21 at 03:53
  • The link did not really help, and seemed to have very little to do with my question. `desktop:dist` tells me less than nothing even after googling for an hour. All I know about my gradle that remotely has anything to do with a Jar is what I will be adding to my post as an edit. @londonBadger – Biohazard Aug 29 '21 at 08:57
  • Open a terminal at the root of your project and type .\gradlew.exe desktop:dist and that will run a predefined task from the libGDX skeleton project that creates a jar in yourProject\desktop\build\libs\desktop-1.0.jar . "dist" is a task in "desktop" to create jar files. Its this line that you have posted "task dist(type: Jar) {" which defines the task to create the jar. – londonBadger Aug 31 '21 at 10:21

0 Answers0