导出带有库的Gradle项目

huangapple go评论97阅读模式
英文:

Exporting Gradle Project with Libaries

问题

我正在尝试导出一个在LWJGL库上运行的Gradle项目。因此,当我尝试使用以下命令导出时:
gradlew clean build
它完成构建,但当我运行它时,它直接崩溃,并显示错误消息:

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFWKeyCallbackI
        at strobe.app.App.main(App.java:23)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFWKeyCallbackI
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

我相信在以前尝试导出带有库的项目时,我曾遇到过这个错误,当时我忘记将它们包含在JAR文件中。所以,我该如何在Gradle构建的JAR中包含这些库呢?因为我一直以为Gradle会替我做这个 =?

英文:

Iam trying to export a Gradle-Project running on a LWJGL libary. So when i try to export it using:
gradlew clean build
it finishes a build, but when i run it it crashes directly with the Error message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFWKeyCallbackI
        at strobe.app.App.main(App.java:23)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFWKeyCallbackI
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

I believe i got this Error before when i tryied to export an Project with libaries and forgot to include them in the jar. So how do i include the libaries in the gradle Build Jar. Because i always thought that Gradle would do that for me =?

答案1

得分: 1

这是解决您问题的最佳文档。请确保您的项目文件结构正确,并重新检查您项目的 build.gradle 文件。

  1. Gradle 文档

  2. 这可能与您的问题无关,但从这些想法中获取灵感,GitHub 上有很多仓库,请浏览一下。例如,使用以下仓库生成带有 Gradle 的 Spring Boot 的 .jar 文件:

    仓库链接

英文:

This is the greatest documentation to resolve your issue. plz make sure that your project file structure was correct and recheck your project's build.gradle file

  1. [Gradle Documentation] 1

  2. this is may not be related to ur question but the idea form those, there are so many repositories on github plz go through it. as an example use the following repository and generate .jar file Springboot with gradle

    Repository Link

huangapple
  • 本文由 发表于 2020年9月17日 22:12:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63939961.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定