JAR Executable much slower than running by Netbeans

Asked

Viewed 548 times

2

Good morning,

I have a project in netbeans that uses Maven to build an executable jar, so far so good. The problem is that when I run the project by ". jar" that is generated by Maven, execution takes much longer to perform certain functions than when I run by netbeans IDE. To get an idea, the start of the program run by Netbeans takes 8 seconds, while in ". jar" it takes approximately 25 seconds. At this beginning I read some configuration files, and digital certificates. Other functions that take longer, such as signing xml documents, which already took a while in the IDE, last an eternity in the ." jar". Also, the strange thing is that my project has few libraries.

I also searched on other topics, I found many saying (like this here) to generate the ". jar" with the option to extract the libraries in the generated file, but I don’t really know how to do it in Maven. I even tried a few ways, but I don’t know if I’m making a mistake, or if it didn’t have any effect.

I’ll post my pom.xml file here to see if anyone has any idea what I can do to fix this.

<?xml version="1.0" encoding="UTF-8"?>
<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>br.com.argus</groupId>
    <artifactId>CronosAuxiliar</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.7</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>  
            <groupId>br.com.samuelweb</groupId>  
            <artifactId>java-nfe</artifactId>  
            <version>3.10.8</version>  
        </dependency>  

        <!--Dependência de Log-->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>br.com.argus</groupId>
            <artifactId>CronosLibNotaFiscal</artifactId>
            <version>[1,)</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>  
            <name>Repositorio Autocom SnapShot</name>  
            <id>Snapshot</id>  
            <url>http://www.autocomsistemas.com.br:8081/nexus/content/repositories/autocom/</url>  
        </repository> 
    </repositories>    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>        
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>br.com.argus.cronos.main.CronosAuxiliar</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>  
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>    
</project>
  • Just to eliminate a few possibilities. Is the JVM you’re using to run Jar the same as the one in Netbeans? You’re passing the same memory settings, etc to the JVM as the Netbeans IDE (take a look at netbeans.conf)). It may be that Uber Jar is really the Garga it, but I would definitely check the environment.

  • I looked in this file, I found out which version netbeans uses, but I don’t know which one my windows is running on the command line :( The commands that are run are the ones on the line "netbeans_default_options"? Because if so, I tried to run here with them and there was error in java. It appeared that the virtual machine stopped working.

  • Hi Lucas, you can use the command java -version to find the JVM version and command for %i in (java.exe) do @echo. %~$PATH:i on Windows CMD to find the way. The switches are the same and the fact of having given error is interesting. It is worth trying at least with the memory ones, e.g. java -Xms1G -Xmx5G -jar MinhaAplicacao.jar.

  • In windows I’m using the version of jre "1.8.0_144-b01" and in netbeans is the version of jdk "1.8.0_05", in fact the application is running on different virtual machines right? The options I was able to put on the command line were these "-J-client -J-Xss2m -J-Xms32m". The others I was putting from one to one and was giving error in all.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.