[SOLVED] The build project cannot run Could not find or load main class

I don’t know much about gradle. This is my first project using gradle. I usually use maven and I use ant when learning jme.

The main class cannot be found .
Searching the forums I found an almost identical question.
The only difference is that I was able to run it properly in the sdk.
However, the constructed jar package cannot be run.



can see it’s working fine in the sdk.

But the run of the built jar package shows that the main class cannot be found
image
image

I checked the MANIFEST.MF file in jar and there was Main-class. I could not figure out the problem for a while. If anyone can find out the problem, please let me know, thank you very much

plugins {
    id 'java'
    id 'application'
    id "de.undercouch.download" version "5.1.0"
    id "io.github.0ffz.github-packages" version "1.2.1" // Plugin for anonymous inclusion of artifacts hosted in github package registry
}

group 'mygame'
version '1.0'

mainClassName = "mygame.main"

repositories {
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}

project.ext {
  jmeVer = '3.6.0-stable'
}

project(":assets") {
    apply plugin: "java"

    buildDir = rootProject.file("build/assets")

    sourceSets {
        main {
            resources {
                srcDir '.'
            }
        }
    }
}

dependencies {

  // Core JME
  implementation "org.jmonkeyengine:jme3-core:$jmeVer"
  implementation "org.jmonkeyengine:jme3-desktop:$jmeVer"
  implementation "org.jmonkeyengine:jme3-lwjgl3:$jmeVer"

  // Suppress errors / warnings building in SDK
  implementation "org.jmonkeyengine:jme3-jogg:$jmeVer"
  implementation "org.jmonkeyengine:jme3-plugins:$jmeVer"
  
  // GUI Library
  implementation 'com.simsilica:lemur:1.16.0'
  implementation 'com.simsilica:lemur-proto:1.13.0'
  
  // Physics Library
   implementation 'com.github.stephengold:Minie:7.5.0'

  // Additional Libraries

  // Assets sub-project
  runtimeOnly project(':assets')
}

jar {
    manifest {
        attributes 'Main-Class': "$mainClassName"
    }
}

image

Your main class is lower case. I’ve had that sort of thing mess up my applications before. Could you try correcting that and seeing what happens?

If you are on windows I’d suggest changing it to something else entirely then change to the correctly capitalised version (or else windows can ignore the name change, as it’s a case insensitive OS).

Also, almost certainly unrelated, but I see some of your other packages are upper case, make sure they are all lower case as that similarly may screw things up)

Thank you for your reply. Let me try

Problem solved

image

Build files are in folder distributions
image
I mistakenly thought that there was something wrong with my java path configuration

2 Likes