Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have never seen a software be released as jar, so how can I make a software be released as exe too?

Tags:

java

jvm

Is everybody thinking that everybody else doesn't release softwares as jar and then releases softwares as exe too?

like image 379
Delirium tremens Avatar asked Nov 30 '22 06:11

Delirium tremens


2 Answers

Java software can be release in a number of ways depending on the target market.

The simplest for the developer (but hardest for the end user) is to just release a jar file (or set of Jar files). On many systems the JAR will be "double-click-able", and so act as an executable. But if the end user does not have Java installed it will not work.
Good if you control the target environment. Also good if you want to target Windows, Mac and Linux all at once. Any platform with Java can run it, including platforms you had not considered.
Bad if you are targeting normal users. It can not do "install tasks", set up anything in the start menu or associate itself with a file type.

Java Web Start is my preference in most cases. It gives a Java based installer and can set up the start menu, associate file types and all that goodness. But does bring up a security box on install.
Good for most cases. You have just the one link for all OSes.
Bad if you suspect the user does not have a JRE installed or you don't want the end user to be aware that the application is written in Java.

You could release a zip file with the Jars in and a .bat file and a .sh file to get the going.
Good for administrators, developers and command line applications.
Bad for end users who don't really know what a bat and shell script are and would have no idea what to do if the script was broken for their system.

A thin .exe wrapper round the Jar file. This gives the impression to the end user that the application is native. They normally come with...

A Java aware installer. This is a native installer (so different installers for Windows, Mac & Linux). This will be able to detect if the target machine has Java installed and if not be able to kick off the installation of the JRE. It will also be able to do all the fun post-install stuff such as setting file associations and add items to the start menu.
Good for most cases.
Bad if you are targeting multiply platforms as you will need to maintain an installer for each platform. Also bad if one of the target platforms does not have a Java aware installer (you will then need to use of of the other methods above for that one platform).

Native EXE. Using a Java-to-native compiler (Jet, GCJ or IKVM) you create a native executable.
Good if you really don't want people to know you are using Java or need to integrate with the native environment in some odd way (ikvm will let you use your Java code in .NET as simply a .NET object).
Bad as people think that this will magically make the application faster when it will not.

A jpm4j package. JPM is a package manager for Java like npm for nodejs. This allows you to install software via a small command line script, for example to install jython you can use jpm install -f --name jython org.python:jython. Good for developer tools. Bad for end users as it is command line based and requires them to first install jpm.

Edit: IKVM, jpm

like image 111
Michael Lloyd Lee mlk Avatar answered Jan 25 '23 22:01

Michael Lloyd Lee mlk


Yes. If you dealing with end users and not programmers, building a native solution for his platfrom is a good idea. Create a dmg, a exe and some linux packages. For exe stuff, take a look at launch4j or jsmooth.

like image 33
Tim Büthe Avatar answered Jan 25 '23 22:01

Tim Büthe