Home > Back-end >  Execution failed for task ':Launcher.main()'. > Process 'command 'C:/Program
Execution failed for task ':Launcher.main()'. > Process 'command 'C:/Program

Time:12-06

I'm following a tutorial on LWJGL and I'm trying to run the project with gradle 7.6 and Java JDK 19. I'm getting the error log

11:56:12 AM: Executing task ':Launcher.main() --scan'...

> Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE

> Task :Launcher.main() FAILED
3.3.1 build 7

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings
2 actionable tasks: 1 executed, 1 up-to-date
[LWJGL] Failed to load a library. Possible solutions:
    a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
    b) Add the JAR that contains the shared library to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll
    at org.lwjgl.system.Library.loadSystem(Library.java:164)
    at org.lwjgl.system.Library.loadSystem(Library.java:63)
    at org.lwjgl.system.Library.<clinit>(Library.java:51)
    at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:100)
    at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
    at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
    at edu.vanier.engine.WindowManager.init(WindowManager.java:35)
    at edu.vanier.test.Launcher.main(Launcher.java:12)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Launcher.main()'.
> Process 'command 'C:/Program Files/Java/jdk-19/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.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? [yes, no] 

Here's the build.gradle per request

    plugins {
    id 'java'
    id 'application'
}

project.ext.lwjglVersion = "3.3.1"
project.ext.jomlVersion = "1.10.5"
project.ext.lwjglNatives = "natives-windows"

repositories {
    mavenCentral()
}

dependencies {
    implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

    implementation "org.lwjgl:lwjgl"
    implementation "org.lwjgl:lwjgl-assimp"
    implementation "org.lwjgl:lwjgl-bgfx"
    implementation "org.lwjgl:lwjgl-cuda"
    implementation "org.lwjgl:lwjgl-egl"
    implementation "org.lwjgl:lwjgl-glfw"
    implementation "org.lwjgl:lwjgl-jawt"
    implementation "org.lwjgl:lwjgl-jemalloc"
    implementation "org.lwjgl:lwjgl-libdivide"
    implementation "org.lwjgl:lwjgl-llvm"
    implementation "org.lwjgl:lwjgl-lmdb"
    implementation "org.lwjgl:lwjgl-lz4"
    implementation "org.lwjgl:lwjgl-meow"
    implementation "org.lwjgl:lwjgl-meshoptimizer"
    implementation "org.lwjgl:lwjgl-nanovg"
    implementation "org.lwjgl:lwjgl-nfd"
    implementation "org.lwjgl:lwjgl-nuklear"
    implementation "org.lwjgl:lwjgl-odbc"
    implementation "org.lwjgl:lwjgl-openal"
    implementation "org.lwjgl:lwjgl-opencl"
    implementation "org.lwjgl:lwjgl-opengl"
    implementation "org.lwjgl:lwjgl-opengles"
    implementation "org.lwjgl:lwjgl-openvr"
    implementation "org.lwjgl:lwjgl-openxr"
    implementation "org.lwjgl:lwjgl-opus"
    implementation "org.lwjgl:lwjgl-ovr"
    implementation "org.lwjgl:lwjgl-par"
    implementation "org.lwjgl:lwjgl-remotery"
    implementation "org.lwjgl:lwjgl-rpmalloc"
    implementation "org.lwjgl:lwjgl-shaderc"
    implementation "org.lwjgl:lwjgl-spvc"
    implementation "org.lwjgl:lwjgl-sse"
    implementation "org.lwjgl:lwjgl-stb"
    implementation "org.lwjgl:lwjgl-tinyexr"
    implementation "org.lwjgl:lwjgl-tinyfd"
    implementation "org.lwjgl:lwjgl-tootle"
    implementation "org.lwjgl:lwjgl-vma"
    implementation "org.lwjgl:lwjgl-vulkan"
    implementation "org.lwjgl:lwjgl-xxhash"
    implementation "org.lwjgl:lwjgl-yoga"
    implementation "org.lwjgl:lwjgl-zstd"
    runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-bgfx::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-jemalloc::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-libdivide::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-llvm::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-lmdb::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-lz4::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-meow::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-meshoptimizer::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-nanovg::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-nfd::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-nuklear::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-opengles::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-openvr::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-openxr::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-opus::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-ovr::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-par::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-remotery::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-rpmalloc::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-shaderc::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-spvc::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-sse::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-tinyexr::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-tootle::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-vma::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-xxhash::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-yoga::$lwjglNatives"
    runtimeOnly "org.lwjgl:lwjgl-zstd::$lwjglNatives"
    implementation "org.joml:joml:${jomlVersion}"
}

test {
    useJUnitPlatform()
}

I've tried every solution I saw online, from updating my Intellij IDE, updating the gradle and JDK versions, updating my JRE. Invalidating caches. I'm really at a dead end here. Any help would be appreciated thanks.

CodePudding user response:

You don't mention what steps you followed to build the project, nor can we see your build.gradle file or the project's structure, but it looks like you tried to manually do some things, unsuccessfully.

In any case, the LWJGL website provides a configurator that simplifies the whole process.

If you want to use Gradle, choose the "Gradle" mode in the generator. This will result in a portion of a build.gradle script containing dependency declarations for all selected modules and platforms, which you can copy/paste into your build.gradle file and use it to build your project.

Note that when using Gradle, you probably want to prepend apply plugin: 'java' and apply plugin: 'application' to the build.gradle file.

Following the above should result in a successful build in IntelliJ, but if not, you can try a custom configuration, following the instructions below (as indicated on LWJGL-Wiki):

  1. Go to the configurator's page, select Zip Bundle, review the options and choose the bindings you're interested in, then click on DOWNLOAD ZIP.
  2. When the download is complete, extract its contents into your project.
  3. In IntelliJ, go to Project Structure > Libraries > New Project Library. Add all LWJGL .jar files (classes natives) to the library and add the library as a dependency to your project module(s). You do not need to extract the native libraries.
  4. If you also downloaded the sources, add the corresponding .jar files as sources to the LWJGL library. You do not need to download and attach the javadoc .jar files, IntelliJ generates javadoc directly from sources.

CodePudding user response:

The problem was with an error being incorrectly thrown. It had nothing to do with LWJGL or Gradle.

  • Related