All this speaks of the difference in performance when packaging in JAR v / s, extraction in the JAR and the difference in performance when starting from Eclipse v / s launched from the console.
Difference in performance when packaging in JAR v / s in JAR:
Extract the required libraries in the JAR:
What does he do:
In this option, Eclipse will retrieve all classes from the specified JARs and packages in the generated JAR.
If you open the JAR, you will find that there are no JAR packages that are not referenced, but all classes of related JAR packages are ordered according to the structure of the package, and then packaged inside the JAR at the root level. This brings a key performance difference compared to the “required jar file packaging libraries”, which additionally costs the deployment and loading of JARs in memory, etc.
When exporting to JARs through Eclipse, performance is the best option. It is also a scalable parameter because you can send this JAR
MANIFEST.MF The main thing in this file is the main class. When you run the JAR, you directly run the class that you need.
Main-Class: com.my.jar.TestSSL
Package of required libraries in the JAR:
What does he do:
In this version, Eclipse will:
- pack all the specified JAR files into the generated JAR.
- use the Eclipse JAR loading mechanism through
org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader , and you can also see the org.eclipse.jdt.internal.jarinjarloader package in your generated JAR, and this package is only under the root directory of the generated JAR.
Now, of course, this is an additional cost that arises when you select this parameter, because when you run the JAR, then you are not executing the main class, and the JarRsrcLoader will be executed, which will load your main class and other libraries, and all the indicated libraries packaged. See section MANIFEST.MF below
MANIFEST.MF The main thing in this file is the main class. When you start the JAR, the JarRsrcLoader will start and continue.
Rsrc-Main-Class: com.cgi.tmi.TestSSL Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Now for the last Eclipse export option - “Copy the necessary libraries to a subfolder next to the JAR”, I don’t think this is a very scalable solution because it imposes a dependency on your file system, so I would say do it.
The difference in performance when starting from Eclipse v / s launched from the console:
When you start the application from Eclipse, it quietly looks like the 1st export option, where Eclipse does not need to parse and load the JAR at runtime and that’s it.
This, however, is a very trivial point, the key is to consider the Eclipse JAR 1 v / s export option.
Final words:- Use the "Extract required libraries in JAR" to export the JAR, and you will see a significant increase in performance.
- It is very unlikely that your socket connections will last long when you start the console, because the JVM runs the code, then it will have the same or very comparable performance when working with Eclipse and the console (given the same versions of Java in both cases). You may feel due to JAR's packaged performance. Try extracting the JAR and everything will be fine.
- Also consider the amount of logging you are doing. When launched, depending on the configuration, Eclipse can mask a lot of logging and therefore save I / O time.
- Understand how classes access from the path of a JAR class , which is like an extra computational cost when you refer to classes from a JAR.