Jump to content
Excelsior Forums
Sign in to follow this  
jaw

Excelsior 15: How to reduce the native file size

Recommended Posts

Thanks for the excellent product.

Now I'd like to prevent ExcelsiorJet from copying all the class file of the 3rd party .jar files into my final native (say .exe) file.

Say if my code depends on ClassA in lib.jar, I don't want ExcelsiorJet to copy also ClassB, ClassC, ClassD inside that lib.jar into my final to be generated app.exe

Versions

- Excelsior 15, JDK 1.8.0_144, Tomcat 8.0, 

How can I do that ?

Thanks

-----------------------------------------

These are the steps I did to achieve an .exe file

1) Use maven-assembly-plugin to put all depended jars into a single jar named client-jar-with-dependencies.jar

    <build>
        <finalName>client</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>-Xms512m</argument>
                        <argument>-Xmx512m</argument>
                        <argument>-XX:NewRatio=3</argument>
                        <argument>-classpath</argument>
                        <classpath/>
                        <argument>com.crcc.btx.ClientRunner</argument>
                    </arguments>
                </configuration>
            </plugin>

            <!-- Maven Assembly Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- bind to the packaging phase -->
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <!-- get all project dependencies -->
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <!-- MainClass in mainfest make a executable jar -->
                            <archive>
                                <manifest>
                                    <mainClass>com.crcc.btx.ClientRunner</mainClass>
                                </manifest>
                            </archive>
                        </configuration>

                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.excelsiorjet</groupId>
                <artifactId>excelsior-jet-maven-plugin</artifactId>
                <version>1.2.0</version>
                <configuration>
                    <mainClass>com.crcc.btx.ClientRunner</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

2) Run the following to have client-jar-with-dependencies.jar

mvn clean package

3) Rename the .jar file because Excelsior only takes client.jar as input

cp client-jar-with-dependencies.jar client.jar

 

4) Generate the exe file on Windows

mvn jet:build

 

Now I would see that excelsior is busy including 15783 files into the final client.exe file, which is 59 MB. This is too much

 

excelsior_generating_exe.png

Share this post


Link to post
Share on other sites

So the questions are

- Am I doing correctly ?

- If yes, then can I do something else to reduce the exe file ?

Share this post


Link to post
Share on other sites
Quote

Say if my code depends on ClassA in lib.jar, I don't want ExcelsiorJet to copy also ClassB, ClassC, ClassD inside that lib.jar into my final to be generated app.exe 

You can use ProGuard for your jars before compiling. It can help you remove some classes, if you believe they are not used. But do not forget to test your app on JRE after that - just to make sure you did not swept used classes by mistake.

 

 

Share this post


Link to post
Share on other sites
On 6/13/2018 at 9:17 PM, zztop said:

You can use ProGuard for your jars before compiling. It can help you remove some classes, if you believe they are not used. But do not forget to test your app on JRE after that - just to make sure you did not swept used classes by mistake.

 

 

Great, I'll try that

Sorry I come here late, because I believe I have not received any email notifying me of a reply.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×