英文:
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
文件。
-
这可能与您的问题无关,但从这些想法中获取灵感,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
-
[Gradle Documentation] 1
-
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论