How to make Java program installable?

前端 未结 6 984
感情败类
感情败类 2020-12-23 23:36

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

相关标签:
6条回答
  • 2020-12-23 23:55

    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>

    0 讨论(0)
  • 2020-12-23 23:59

    You can use Java WebStart, or package the program as an executable jar file.

    0 讨论(0)
  • 2020-12-24 00:08

    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.

    0 讨论(0)
  • 2020-12-24 00:08

    I'm risking a flamewar here but I'm game :) Unless you're on a platform where the JRE is already known to exist (ex. OS X) it's going to be a hassle for you and/or end users. The problem is java apps are simply not standalone and depend on a massive framework.

    The JRE, Java Web Start, or whatever you use has to be put on the target system. Also you have to have a launcher of some sort. It could be something as simple as a script which runs java, supplies the classpath, etc. This wouldn't be needed if java "compiled" to an .exe or something but that's just how it works.

    This is one of the reasons I've turned off on deploying Java to end-user machines. It's just a lot of trouble. I once worked on a project where we actually embedded an entire private jre that got deployed by the installer. It wasn't pretty but it got the job done.

    0 讨论(0)
  • 2020-12-24 00:09

    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

    0 讨论(0)
  • 2020-12-24 00:11

    Guys already gave you a lot of options so I do not want to mention them again. The only option that is missing here is a case when you really need to install your program, meaning execute some logic, modify (or at least read) system configuration, create desktop shortcuts, copy many files, configure third party products (that are probably already installed) etc.

    In this case you can use InstallAnywere, EzPack or similar solutions (see http://java-source.net/open-source/installer-generators) For example if your project is relatively simple I'd recommend you AntInstaller.

    BTW if you afraid that your customer probably does not have JRE installed on his machine you can package your code (or better a loader) using Launch4J that generates executable from your java code.

    0 讨论(0)
提交回复
热议问题