Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runnable jar runs too slow compared to eclipse project

I have extracted a jar file from an eclipse project but it runs too slow. It takes almost twenty minutes to complete and the eclipse project only takes some seconds. I exported runnable jar with library handling with all three differenct choices. I also exported jar file with all library handling choices. I also run jar file with command:

java -Xmx2048m -Xms1024m -jar "finalJar.jar"

I have removed all System.out.println except the last one that gives me the answer. What can I do to export a jar that is almost fast as the original project? Or run it with a different way to be faster? Because the difference in time is too big and I don't understand why.

like image 278
user1431148 Avatar asked Dec 04 '22 07:12

user1431148


1 Answers

Using the option "Extract required libraries into generated file" helped me a lot, it's faster now.

The option "Package required libraries into generated JAR" copy the libs you use as jar files into your own jar file and the JVM needs to open it (or even extract if it's compacted) when you run the application.

like image 182
Rodolfo Avatar answered Dec 26 '22 12:12

Rodolfo