Help create a working JAR file of my project, made using the libgdx framework. I tried to make it through Project Structure -> Artifacts -> Create JAR from Modules, I created a JAR file that launches the application for 1 second with a black screen and then closes without an error.

UPD1: With the help of Gradle I created a JAR file, but it still does not start the game, but an error has been found. The problem was that all project images are not loaded due to the “wrong path”. They are stored in the assets folder and therefore I upload them via Gdx.files.internal ("img_name.png"). Is it possible that the compiled JAR file is looking for files in the wrong path?

    2 answers 2

    All right, the program closes after execution.

    Try the command line:

    java -jar jarName.jar 

    Options:

    1. Specify the full path to the jar, if you are in another directory.

    2. Specify the full path to the java compiler if the java_home environment variable is not specified

    3. When launching, specify the class with the executable main method, if it was not specified in the manifest when building:

       java -jar jarName.jar -cp package.ClassWithMainMethod 
    • You use libgdx, as far as I know, it uses gradle when building. Those. The normal way to create a project is to configure the project in the libgdx wizard and import via gradle. I advise you to build a project not a standard Intellij IDEA collector, but a gradle. View-Tools Windows - Gradle. And call the task - build. And then, most likely, a normal dextup application will be assembled, which can be launched by a regular click without cmd. - Evgeny Vasin September
    • Yes, I have gradle installed, the project uses build.gradle and settings.gradle, but there is no button that you described in "View-Tools Windows - Gradle". Maybe from the command line, you can somehow call the build project? - Praytic

    You can create through the console. 1. Open the console 2. write cd "path to the folder in which gradlew lies (that is, the folder with your project)" without quotes 3. Next gradlew desktop: dist (if you want for android, then gradlew android: dist) lie in <Folder with your project>> desktop> build> lib I always collect all projects in this way without problems)