P
P
Praytic2015-09-05 18:03:22
Java
Praytic, 2015-09-05 18:03:22

How to create a working JAR file in Intellij IDEA?

Please help me create a working JAR file for my project made with the libgdx framework. I tried to do it through Project Structure -> Artifacts -> Create JAR from Modules, a JAR file was created that starts the application for 1 second with a black screen and then closes without error.
UPD1: I created a JAR file using Gradle, but it still does not launch the game, but an error was found. The problem was that all project images fail to load due to "wrong path". They are stored in the assets folder and therefore I load them via Gdx.files.internal("img_name.png"). Is it possible that the compiled JAR file is looking for files in the wrong path?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
qor1x, 2015-09-07
@Praytic

Maven
pom.xml

<plugin>
    <groupId>com.zenjava</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>8.1.2</version>
    <executions>
        <execution>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>MainApp</mainClass>
        <vendor>Company</vendor>
        <jfxAppOutputDir>target/jfx</jfxAppOutputDir>
        <verbose>true</verbose>
        <appName>App</appName>
    </configuration>
</plugin>

Build project via Maven -> Install. IDEA has it - i.imgur.com/7ucuVDH.png
Target/jfx/ will contain the required jar file. And yes, as mentioned above, a jar nickname will also appear in the target/ directory itself, but a non-working one

V
Valera Programmer, 2015-09-07
@noddux

I had a similar problem but on Maven.
the code was compiled into 2 jar files, one jar included dependent libraries, the other did not.
and I ran a jar that didn't pack the libraries... what a pain it was!)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question