JAR executable pros and cons

I use JAR files to export my projects for Java in school. I noticed that this is portable (assuming Java is used on the computer). However, with this fact, why didn't I see developers distribute Java programs using a JAR file? What are the pros (besides portability) and cons (other than using C ++) of using the JAR executable?

+4
source share
2 answers

I hope the benefits are pretty obvious. The biggest flaw I encountered is when additional dependencies are required that are not included in the JAR. MANIFEST can be enabled to set the class path, but this requires that all dependencies exist with predefined names in a predefined location. This can be handled using the script loader (to set the class path, etc.) - at this point, not everything is contained in the same JAR, and most of the benefits are lost.

+4
source

There are two questions. The first is JAR delivery and without installation. The second component of the question is the pros and cons of using only the JAR on the machine after deploying the executable. I'm starting to suspect that the OP was asking about the first component. My answer is trying to answer the second component.

Arguments

  • Less work. You do not need to make an executable file for each platform that you want to support.

vs

  • If the user has not installed java, he cannot tell the user why he cannot work. Exe can also download java for the user.
  • If your application requires a specific version of Java, it may work with the wrong version. The native executable can find the correct one and use it. This point is not as important as before, since Java 6 has been around for so long.
  • Unable to configure custom icon for executable file in Windows.
  • You cannot control startup parameters, such as the maximum memory that your application can use. For most applications this is fine, but sometimes you need more memory.
  • Cannot use JAR for Windows service. There should be an exe shell (jsmooth has this).

Another alternative to creating an executable is to use JNLP. A web page can check java before it redirects the user to a .jnlp file.

+5
source

Source: https://habr.com/ru/post/1382346/


All Articles