Can't run any Project. Error: Could not find or load main class com.mygame.Main and more

I am trying to learn jMonkeyEngine, but whenever project I create I am unable to run it and continue development. Please help. I have done everything as in documentation, but I cant run demo.

It says

`JAVA_HOME=“C:\Program Files\jmonkeyplatform\jdk”
cd C:\Users\coils\Desktop\Projects\аss6\jMonkeyEngine\HelloWorldTutorial; .\gradlew.bat --configure-on-demand --configuration-cache -x check -x test run
Configuration cache is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: run
Configuration on demand is an incubating feature.

Task :compileJava UP-TO-DATE
Task :processResources NO-SOURCE
Task :classes UP-TO-DATE
Task :assets:compileJava NO-SOURCE
Task :assets:processResources NO-SOURCE
Task :assets:classes UP-TO-DATE
Task :assets:jar UP-TO-DATE

Task :run FAILED
Error: Could not find or load main class com.mygame.Main
Caused by: java.lang.ClassNotFoundException: com.mygame.Main

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ‘:run’.

Process ‘command ‘C:\Program Files\jmonkeyplatform\jdk\bin\java.exe’’ finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

2: Task failed with an exception.

  • What went wrong:
    Configuration cache problems found in this build.

1 problem was found storing the configuration cache.

  • Task :run of type org.gradle.api.tasks.JavaExec: cannot serialize object of type ‘’, a subtype of ‘’, as these are not supported with the configuration cache.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.

3 actionable tasks: 1 executed, 2 up-to-date
Configuration cache entry discarded with 1 problem.

As far as I know it should run as it is an and show to initial demo with rectangle.Thank you for the reading. I tried creating new projects, reinstalling JDK, reinstalling the program, renaming the Main classpath , new Projects with different settings , but without any success. I am feeling stuck. And sorry if my question is noob, it is just I am new to programming with java .

Please show us you build.gradle (as text). And also your file structure.

And you do have com.mygame.Main, right?

How did you create your project?

1 Like

In my project it is named only as com.mygame. I renaimed it now and the problem persist. Now I am gonna try install jMonkeyEngine on my wife’s laptop and see if the problem is in my PC or I am the noob. I created the project in several ways . One was with the online initializer here, one was automatically through jMonkeyEngine app. I created one manually importing JME as external library in Eclipse and had similar problem, but i prefer to make native app runnable.

Here is file structure :

Project is saved on desktop:

C:\Users\coils\Desktop\Projects\аss6\jMonkeyEngine\HelloWorldTutorial …

Here is build.gradle as text :

plugins {
    id 'java'
    id 'application'

group 'com.mygame'
version '1.0'

mainClassName = "com.mygame.Main"

repositories {
    maven { url '' }

project.ext {
  jmeVer = '3.5.2-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"

  // Additional Libraries

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

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

Looks like your package is called com.mygame.Main, so the fully qualified name of your class is com.mygame.Main.Main. Convention in java is to use lowercase for package names to avoid confusion.

If you right click the package in the project tree (the thing that looks like a parcel with com.mygame.Main next to it and refactor it to com.mygame I think everything should work?

the package name is derived from the folder structure, so you have something like /src/main/com/mygame/Main/ as the path to your class - it should be more like /src/main/com/mygame/


I tried to rename it as you write it but the problem persist. I tried JME on other pc and it run as it should . I will reinstall windows, because it seems that the problem is drivers or something in the system.

And the problem is solved with re-installing windows . I am using LENOVO Ideapad Gaming 3-15ACH6 Laptop - Type 82K2 with windows 11 22H2. I will closely monitor as I will further bring back my drivers and other programs for conflicts and report here if I find some reason and link behind this problem. Same project was running fine on other PCs as well as whole same version of JME.

1 Like