I am currently using libgdx and IntelliJ to develop a real-time space 4x game. I ran into an issue, where I am trying to include lua scripts in my project (for the sake of allowing players to mod new behaviors into my game), and I ran into a slight issue.
In the past, using Eclipse, I had only ever needed to download pre-compiled binaries/.jar files, select them using Eclipse's built-in GUI, and import them into my project. I've literally never used a dependency management system like Gradle, and I don't really know how to add dependencies to my project. I've tried File -> Project Structure -> Libraries -> New Project Library, choosing Maven, and getting the following window:
Now, if I add this as a dependency to all of my projects, I get no errors:
Until it comes time to compile - the compiler is unable to resolve the imported LuaJ packages.
So, what is going on, how do I fix it? How do I, in a simple and straightforward way, add dependencies to my project (the project was generated using the default templates provided by the libgdx team)?
9:54:18 AM: Executing ':lwjgl3:org.origin.spacegame.lwjgl3.Lwjgl3Launcher.main()'...
> Task :core:compileJava FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.10.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
1 actionable task: 1 executed
C:\Users\djack\Desktop\LibGdx Games\Space Game\core\src\main\java\org\origin\spacegame\game\GameInstance.java:11: error: package org.luaj.vm2 does not exist
import org.luaj.vm2.Lua;
^
C:\Users\djack\Desktop\LibGdx Games\Space Game\core\src\main\java\org\origin\spacegame\game\GameInstance.java:42: error: cannot find symbol
Lua l;
^
symbol: class Lua
location: class GameInstance
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
BUILD FAILED in 947ms
9:54:19 AM: Execution finished ':lwjgl3:org.origin.spacegame.lwjgl3.Lwjgl3Launcher.main()'.
Steps to re-create the issue:
Generate a new libgdx project using the libgdx project generator: libgdx.com/wiki/start/project-generation
Import the project into IntelliJ.
File -> Project Structure -> Libraries -> New Project LibrarySelect "from maven."
Type "luaj" and wait for the IDE to find a list of maven repos.
Select
com.diamondq.org.luaj:luaj-jse:3.0.2-SNAPSHOTMake sure transitive dependencies, sources, javadocs, and annotations are all selected.
Click "OK" in the bottom right corner of the "Download Library from Maven Repository" window.
Click "Apply" in the bottom right corner of the Project Structure window.
Click "OK" in the bottom right corner of the Project Structure window.
Import LuaJ into the application adapter in your
coreproject.When an error appears, hover your mouse over the code and select "import into classpath."
Once the error goes away, try to build/run your project.



{}icon above the editing window generally handles most code formatting. If you need more info you can check our formatting guide. \$\endgroup\$