Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAR executable pros and cons [closed]

I have been using JAR files to export my projects in my Java subject at school. I noticed it's portability (assuming the computer in use has Java installed). However, with that fact, why haven't I seen developers distribute Java programs using a JAR file? What are the pros (besides portability) and cons (aside from using C++) of using the JAR executable?

like image 309
Joseph Avatar asked Jan 18 '23 05:01

Joseph


1 Answers

There are two components to the question. The first is shipping a JAR and using no installer. The second component to the question is the pros and cons of a using just a JAR on the machine once the executable has been deployed. I'm starting to suspect that the OP was asking about the first component. My answer tries to answer the second component.

Pros

  1. Less work. Don't have to make an executable for each platform you want to support.

Cons

  1. If the user doesn't have java installed it can't tell the user why it can't run. An exe can also download java for the user.
  2. If your app requires a specific version of Java it may run with the wrong version. A a native executable can locate the correct one and use it. This point isn't as important as it used to be since Java 6 has been around so long.
  3. Can't have an customized icon for the executable on Windows.
  4. You can't control startup options such as the maximum memory that your app can use. For most apps this is ok but sometimes you need more memory.
  5. A JAR cant be used for a Windows service. There must be an exe wrapper around it (jsmooth has this).

Another alternative to producing an executable is to use JNLP. A web page can check for java before it forwards the user to the .jnlp file.

like image 79
Sarel Botha Avatar answered Jan 25 '23 01:01

Sarel Botha