0

I have my own project(https://github.com/reinvert/CrossStitchConverter)

And I always compile the project on eclipse by File-Export-Runnable JAR File-(Library handling)Package required libraries into generated JAR.

It works fine, but the jar file size is too big(83.0MB)

How can I reduce the file size?

I tried jlink, jpackage, and etc, but none of those have an effect.

This is my pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>CrossStitchConverter</groupId>
    <artifactId>CrossStitchConverter</artifactId>
    <version>1</version>
    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <configuration>
                    <mainClass>CrossStitchConverter</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>io.github.palexdev</groupId>
            <artifactId>materialfx</artifactId>
            <version>11.13.3</version>
        </dependency>
    </dependencies>
</project>

I found large library file(JavaFX-web-17.0.2-linux.jar and JavaFX-web-17.0.2-win.jar, which is total 50MB) in exported jar file, so I deleted these file and tried to run jar file, it worked. I think other unused jar library can be removed as those, but I can't find an option for it.

Reinvert
  • 1
  • 1
  • Who will use your app? how many users? on what platforms? how will they obtain it? how will they install it? how will they uninstall it? how will they run it? what is too big? what is not too big? how will they update it? I see so many questions about jar packaging for JavaFX applications, even though it is not recommended (see [javafx tag packaging info](https://stackoverflow.com/tags/javafx/info)). I just wonder what the answers to these kind of questions are because nobody provides that info in the questions. – jewelsea Apr 05 '22 at 12:24
  • If you want jar packaging in the smallest possible jar file, then rely on a JRE install that includes JavaFX, e.g. Liberica "Full JRE" or Zulu "JRE FX" or a custom JRE you create using jlink. – jewelsea Apr 05 '22 at 12:27
  • 1
    JavaFX-web-17.0.2-linux.jar is the web engine for Linux. JavaFX-web-17.0.2-win.jar is the WebEngine for Windows. I do not know why you were exporting these because your project does not use them. – jewelsea Apr 05 '22 at 12:30
  • I finally resolved it. I rebuilt my pom.xml file, and exported to jar file(same menu option), it reduced to 11MB(no need to proceed jlink, because google json library kept it from jlink command). For someone who suffer this problem, I leave my pom.xml file which is finally resolved. https://github.com/reinvert/CrossStitchConverter/blob/master/pom.xml – Reinvert Apr 08 '22 at 07:16

0 Answers0