Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Java program installable?

How can I make a java program installable?

I have an application saved in my Eclipse workspace.

I can export it as a .jar file.

This is for a "real-world" application.

How can I export to be a ".exe" file or ".dmg" so that it can be installed on another machine?

Since Java is platform-independent I think it is a matter of exporting for a specific operating system.

I've googled a lot and read so many different stories, so I would prefer an answer from an experienced person.

like image 280
JBoy Avatar asked Apr 19 '11 06:04

JBoy


3 Answers

As of Java 8, jdk is now capable of generating it's own Installables for Windows, OSX, and Linux. However, on Windows it depends on either Inno Setup 5 or later or WiX 3.0 or later.

https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#A1324980

The easiest way to produce a self-contained application is to modify the deployment task. <fx:deploy width="${javafx.run.width}" height="${javafx.run.height}" nativeBundles="all" outdir="${basedir}/${dist.dir}" outfile="${application.title}"> <fx:application name="${application.title}" mainClass="${javafx.main.class}"/> <fx:resources> <fx:fileset dir="${basedir}/${dist.dir}" includes="*.jar"/> </fx:resources> <fx:info title="${application.title}" vendor="${application.vendor}"/> </fx:deploy>

like image 173
efaj Avatar answered Sep 22 '22 00:09

efaj


I guess what you are looking for is not only to make the program runnable (as lobster1234 proposed) but to make it actually installable. We have recently used IzPack. It actually looks nice.

There are also some decent tutorials on the details here and here

like image 9
kostja Avatar answered Oct 20 '22 22:10

kostja


Jar files are usually the way to go, since the JVM can directly execute the packaged files through the java -jar <jarfile> command. Java WebStart is good if you want to distribute your app from a web site, etc. However, some OS don't have that "feature" installed, even if the JVM is there. Another solution is to have at least 3 scripts to launch your app (batch for Windows, shell script for Linux, and whatever Mac needs -- sorry, don't have a Mac -- ).

Don't create native executable files (i.e. exe for Windows), they are redundant since you already have a JVM for that.

like image 4
Yanick Rochon Avatar answered Oct 20 '22 22:10

Yanick Rochon