Create Windows Installer for Java Programs [closed]
Asked Answered
S

9

45

I'm a Java beginner.

I already created a simple GUI application that display will "hello world" label.

But, how can I create an installer from .java or .jar for windows. Let's say that I have created a useful application and want to share it with my friends to install it in their PC without they need to know what is JRE, or how to download JRE.

Siddons answered 22/3, 2011 at 19:13 Comment(0)
M
10

Deploy the app. from a web site using Java Web Start. Ensure the user has the minimum Java using deployJava.js (linked from the JWS info page).

Update

The Java Plug-In (used to deploy both applets and webstart applications) was deprecated around Java 9 and removed from the API soon after. This is no longer a viable option.

Middlebreaker answered 22/3, 2011 at 19:42 Comment(10)
Always the best way to use whenever possiblePhilcox
Java Web Start application launcher works fine if you are trying to deploy a Java application over a network where a server is needed to host the required files, that is web-deployed. It only transfers JAR files from the web server to the client. It is similar to .NET Click Once technology, though. It doesn't work if you are trying to distribute over physical media like CD/DVD, etc. as a shrink-wrapped product (the normal distribution method).Zamora
Java Web Start is the easiest way to deploy Java applications. It will work for any platform supported by Java. But users have to have JRE installed before they can use your application, and you can provide instructions on how to install it.Pretentious
@Zamora "It doesn't work if you are trying to distribute over physical media like CD/DVD, etc. as a shrink-wrapped product (the normal distribution method)." Sure. Once it was normal to deliver software on floppy disk. I have 3 working computers at the moment. A 486 has a floppy disk & CD drive. An Intel Core 2 Duo has CD/DVD, USB & internet. A Netbook has USB, card reader & internet (e.g. no CD or DVD). Since flash drives (USB) & digital memory cards are expensive, I'd posit that on-line distribution is the best fit for most end-users in this decade.Middlebreaker
@Alexey Ivanov "..But users have to have JRE installed before they can use your application, and you can provide instructions on how to install it." (Sigh) I thought I made it clear how to make the JRE versioning/installation painless when I added (& this time louder) "Ensure the user has the minimum Java using deployJava.js (linked from the JWS info page)."Middlebreaker
@Andrew I read this; anyway users will have to install a JRE first.Pretentious
@Alexey "..users will have to install a JRE first." Yes, that is true (unless the OS came standard with Java - which is unlikely). But ultimately the same is true of your suggestion. The real difference in our approach seems to be 'off a disc' as opposed to 'off the net'. I maintain that an on-line download is becoming much more common for software in this day & age, and most users have such fast connections they barely notice it. Add that to the automatic update that JWS offers for an app. & the automatic upgrade users get from the latest JRE, and there is a compelling case for JWS.Middlebreaker
@Andrew My suggestion is to package both JRE and the application; the install package can be downloaded from the net. Windows Installer packages also provide Upgrade functionality. I don't argue that JWS is the easiest way to deploy Java applications. Yet I think the deploy/install strategy will heavily depend on the target users and their skills. Some could be happy to download JAR file and run it without any installers at all.Pretentious
Very soon, Oracle will not permit any applets or JWS applications to run unless they have been approved by a verified publisher. Just a friendly warning to anyone who hit this question from Google (like I did), this answer will soon be outdated unless the developer is willing to pay the required fees to get verified. java.com/en/download/help/appsecuritydialogs.xml#selfsignedSalable
Java Web Start used to be a good solution, but now it has many potholes. Instead you will want to use platform-specific installers on top of Java Web Start, or instead of.Vancouver
V
15

From here:

Open Source Installers Generators in Java

IzPack

IzPack is an installers generator for the Java platform. It produces lightweight installers that can be run on any operating system where a Java virtual machine is available. Depending on the operating system, it can be launched by a double-click or a simple 'java -jar installer.jar' on a shell. The most common use is to distribute applications for the Java platform, but you can also use it for other kinds of projects. The main benefit of IzPack is that it provides a clean and unique way of distributing a project to users using different operating systems.

VAInstall

VAInstall is a multi-platform installer written in Java. It is distributed under the GNU GPL License 2. Through a simple config file, it allows the packager to pick files and directories from various places on disk, and not only one root dir like other installers. The packager can completely reorganize the files and dirs on the destination host. He can choose the install mode for the destination host (graphic, xtra, text or ansi).

Packlet

Packlet is a simple installer tool for Java. A packlet is similar to a zip or tgz file: it packages an application into a single compressed file that can be distributed. Packlet files are Java class files that can be executed on any machine with Java 2 Runtime Environment installed. Executing a packlet brings up an installer gui to configure and unpack the application.

Lift Off Java Installer

Lift Off Java Installer is an installer for Java applications. Highlights are self-extracting class files, minimal requirements for the Java installation on the target system, and cross platform installation.

Mini Installer

A simple package to build self installating programs in Java. The process is script driven, the result is a unique JAR file that the user can double click to execute a wizard-like installation process.

JSmooth

JSmooth is a Java Executable Wrapper that makes a standard Windows executable binary (.exe) from a jar file. It makes java deployment much smoother and user-friendly, as it is able to find a Java VM by itself. When no VM is available, it provides feed-back to the users, and can launch the default web browser to an URL that explains how to download a Java VM. Note: NOT COMPLETELY WRITTEN IN JAVA

Launch4J

Windows native executable (.exe) java application wrapper. Offers native splash screen, application icon, search for JRE or use bundled one, feedback on startup failure, passes command line arguments.

AntInstaller

AntInstaller is an installer framework which uses a simple XML file to define the UI, and Apache Ant as a back end. The installers can therefore do anything Ant can, and are compatible with Ant's extension mechanism. Installers can be packaged as a selfextracting Jar and can run from the command line or a Swing GUI. AntInstall can also be used as a GUI front end for existing Ant builds.

Antigen

Antigen (Ant Installer Generator) is a tool to take an Ant build script, combine it with a GUI and wrap it up as an executable jar file. Its primary purpose is to create powerful graphical installers from Ant scripts.

Java Service Wrapper

The Wrapper makes it possible to install a Java Application as a Windows NT Service. The scripts provided with the Wrapper also make it very easy to install those same Java Applications as daemon processes on UNIX systems. The Wrapper correctly handles user log outs under Windows, service dependencies, and the ability to run services which interact with the desktop.

Verbiage answered 22/3, 2011 at 19:17 Comment(2)
All installers I found on your web site require an installed Java VM or automatically download and install it. If your user works on a machine with restricted rights, this is not an option. However, the question from @Amri was how to create an exe from a jar that can be started as is.Plumb
Most of these require a JRE on the machine already. Launch4J is viable to answer this question from that list maybe one other.Vancouver
M
10

Deploy the app. from a web site using Java Web Start. Ensure the user has the minimum Java using deployJava.js (linked from the JWS info page).

Update

The Java Plug-In (used to deploy both applets and webstart applications) was deprecated around Java 9 and removed from the API soon after. This is no longer a viable option.

Middlebreaker answered 22/3, 2011 at 19:42 Comment(10)
Always the best way to use whenever possiblePhilcox
Java Web Start application launcher works fine if you are trying to deploy a Java application over a network where a server is needed to host the required files, that is web-deployed. It only transfers JAR files from the web server to the client. It is similar to .NET Click Once technology, though. It doesn't work if you are trying to distribute over physical media like CD/DVD, etc. as a shrink-wrapped product (the normal distribution method).Zamora
Java Web Start is the easiest way to deploy Java applications. It will work for any platform supported by Java. But users have to have JRE installed before they can use your application, and you can provide instructions on how to install it.Pretentious
@Zamora "It doesn't work if you are trying to distribute over physical media like CD/DVD, etc. as a shrink-wrapped product (the normal distribution method)." Sure. Once it was normal to deliver software on floppy disk. I have 3 working computers at the moment. A 486 has a floppy disk & CD drive. An Intel Core 2 Duo has CD/DVD, USB & internet. A Netbook has USB, card reader & internet (e.g. no CD or DVD). Since flash drives (USB) & digital memory cards are expensive, I'd posit that on-line distribution is the best fit for most end-users in this decade.Middlebreaker
@Alexey Ivanov "..But users have to have JRE installed before they can use your application, and you can provide instructions on how to install it." (Sigh) I thought I made it clear how to make the JRE versioning/installation painless when I added (& this time louder) "Ensure the user has the minimum Java using deployJava.js (linked from the JWS info page)."Middlebreaker
@Andrew I read this; anyway users will have to install a JRE first.Pretentious
@Alexey "..users will have to install a JRE first." Yes, that is true (unless the OS came standard with Java - which is unlikely). But ultimately the same is true of your suggestion. The real difference in our approach seems to be 'off a disc' as opposed to 'off the net'. I maintain that an on-line download is becoming much more common for software in this day & age, and most users have such fast connections they barely notice it. Add that to the automatic update that JWS offers for an app. & the automatic upgrade users get from the latest JRE, and there is a compelling case for JWS.Middlebreaker
@Andrew My suggestion is to package both JRE and the application; the install package can be downloaded from the net. Windows Installer packages also provide Upgrade functionality. I don't argue that JWS is the easiest way to deploy Java applications. Yet I think the deploy/install strategy will heavily depend on the target users and their skills. Some could be happy to download JAR file and run it without any installers at all.Pretentious
Very soon, Oracle will not permit any applets or JWS applications to run unless they have been approved by a verified publisher. Just a friendly warning to anyone who hit this question from Google (like I did), this answer will soon be outdated unless the developer is willing to pay the required fees to get verified. java.com/en/download/help/appsecuritydialogs.xml#selfsignedSalable
Java Web Start used to be a good solution, but now it has many potholes. Instead you will want to use platform-specific installers on top of Java Web Start, or instead of.Vancouver
P
8

You can use WiX to create Windows Installer package. The package will include the JRE binaries and your compiled application (jar file). Upon installation, the installer unpacks your files to user's computer, creates shortcut that starts your application (app-path\jre\bin\javaw.exe -jar app-path\your-app.jar).

See notes on Redistributing the JRE and in README.

Pretentious answered 23/3, 2011 at 8:7 Comment(0)
Y
6

You can use either NSIS or Inno Setup

Yorick answered 22/3, 2011 at 19:16 Comment(0)
C
5

I use a program called JSmooth. This turns java .jar files into executables. I then take those executable and create a installer using InstallShield. InstallShield allows you to create highly customizable installers. There is a free "Light Edition" that you can use. Very easy to do and very easy to add to build scripts.

Corundum answered 23/3, 2011 at 19:30 Comment(0)
Z
2

You can use Ant task tool with InnoSetup and Launch4j under Eclipse IDE to create a professional-looking Windows-based EXE installer for Java-based program: How to create an exe file in java

Zamora answered 22/3, 2011 at 22:50 Comment(3)
How does that work for users of Macintosh & *nix? At no point did the OP mention targeting Windows.Middlebreaker
@Andrew Thompson: OP does mention Windows...he said But, how can I create an installer from .java or .jar for windows :) Apache Ant does support some non-Windows OSes; it is a Java-based tool, anyway. For non-Windows OSes, you need to change the tools/scripts in the Ant task script (this is out of my experience).Zamora
"OP does mention Windows" My bad. Missed that even in my 2nd reading of it! :(Middlebreaker
J
1

You can use the install4j for the create exe file for jar file of java project and use the Inno Setup Compiler file for create the installer for the project. this ts Youtube vedio for the how to create the exe and installer

video for create the exe and installer

Jell answered 23/4, 2013 at 12:12 Comment(0)
C
0

Basically, you have to save your project in jar and then convert to exe, you can use jar4exe or other software. When you have the exe file, use an installer software like Inno Setup Compile or other. After all those stpes Your project will be ready to be install in windows, mac or linux platform. Good Luck.

Capias answered 3/10, 2015 at 21:53 Comment(2)
Inno Setup only runs on WindowsVancouver
Yes Inno Setup just run on windows and it is just an installer software but your exe file can run in windows, mac and linux, thank to jar4exe.Capias
M
0
  1. Install exe4j

    • This you will use to create a .exe file from a jar file
  2. Install inno setup compiler

    • This is used to create installer

An outdated but relevant video to guide you through https://www.youtube.com/watch?v=kSmhIunxVW4

Mra answered 6/12, 2017 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.