0

I have been working on a desktop app using javafx and maven, in this project i also use apache poi to read some excels and h2 database to make a temporary database. I have been able to make it run perfectly in intellij idea, but i can't for the life of me deploy it in .jar and run it outside of the idea.I tried doing it using javfx:jlink but it fails with this error: error

Here also a link for the repository in github:github repository

Please thats the only thing left to do.Any help is appreciated.

  • 3
    Please see https://github.com/dlemmermann/JPackageScriptFX. – CrazyCoder Aug 22 '20 at 23:29
  • Yes, follow the advice of @CrazyCoder and don't use fat jars. They do not work well with JavaFX beyound Java 11. You cannot use jlink directly because it does not support automatic modules (see your error message). Disclaimer: I am biased because I am the co-author of the above mentioned tutorial :-) – mipa Aug 23 '20 at 07:01

1 Answers1

0

As far I know you're able to use fat-jar to bring all dependencies with your application and pack it into single fat-ultrasomma.jar file.

You'll run the app by using the next command:

$ java -jar target/fat-ultrasomma.jar

To do that you need to add a shade plugin

<build>
        <plugins>
           ...
           ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>fat-ultrasomma</finalName>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>ultrasomma.Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

And a Main.java class for execution

public class Main {
    public static void main(String[] args) {
        App.main(args);
    }
}

Links:

rostIvan
  • 264
  • 1
  • 8