如何打包 Java 桌面应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7915315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 22:00:31  来源:igfitidea点击:

How can I package a Java desktop application?

javadistribution

提问by Niklas

I am working on a simple desktop java application. I would like to make it as seamless to install for end users as possible. E.g. similar to how Minecraft is distributed - a simple executable for OS X and an EXE file for Windows.

我正在开发一个简单的桌面 Java 应用程序。我想让最终用户尽可能无缝地安装。例如,类似于 Minecraft 的分发方式——OS X 的简单可执行文件和 Windows 的 EXE 文件。

What tool should I use?

我应该使用什么工具?

回答by Alba Mendez

Users of your Java app must have the JRE installedin order to run it.
You can either tell them to install Java first, or distribute JRE with your app, as Processingdoes.
Note, however, that your packaged program will be heavy if you include JRE with it. And, if you want to do that, users will need to download the appropiate package for their platform.

您的 Java 应用程序的用户必须安装 JRE才能运行它。
您可以告诉他们首先安装 Java,或者像Processing一样将 JRE 与您的应用程序一起分发。 但是请注意,如果您的打包程序包含 JRE,那么它会很重。而且,如果您想这样做,用户将需要为其平台下载合适的软件包。

Executable Java Wrappers

可执行的 Java 包装器

They take your Java app as input and wrapthem in an executable (for a specified platform). You can customize them as you like; and if the user doesn't have Java installed, the download page will open.

它们将您的 Java 应用程序作为输入并将它们包装在可执行文件中(针对指定平台)。您可以根据需要自定义它们;如果用户没有安装 Java,下载页面将打开。

Some examples are Launch4J, JSmoothand Jar2EXE.
 

一些示例是Launch4JJSmoothJar2EXE
 

Installers

安装人员

They are independent applications configured to copyyour app files to the user's computer and (optionally) create a shortcut.

它们是独立的应用程序,配置为您的应用程序文件复制到用户的计算机并(可选)创建快捷方式。

Some installers are written in Java, so they're multiplatform. In this case, the installer is a .jar.
Some others are platform-dependent, but you have the advantage that you don't need to wrap them.

一些安装程序是用 Java 编写的,因此它们是多平台的。在这种情况下,安装程序是一个.jar.
其他一些是平台相关的,但您的优点是不需要包装它们。

Java installers:IzPack, Packlet, PackHymanet, Antigen, …
 

Java 安装程序:IzPackPackletPackHymanetAntigen……
 

Java Web Start

Java Web 入门

It's a Java feature that allows you users to easily run your apps. You give them a .jnplfile,
they open it, and Java downloads the latest version of your app and runs it. No packaging troubles!

这是一项 Java 功能,可让您的用户轻松运行您的应用程序。你给他们一个.jnpl文件,
他们打开它,Java 下载你的应用程序的最新版本并运行它。没有包装烦恼!



See the complete list of resources here.

此处查看完整的资源列表。

回答by jjchiw

Java Web StartI think is the option you're looking for...

Java Web Start我认为是您正在寻找的选项...

回答by Andrew Thompson

The optimal installation for a cross-platform app. with a GUI is to be found in Java Web Start. To quote the linked document in part:

跨平台应用程序的最佳安装。可以在Java Web Start 中找到带有 GUI 的内容。部分引用链接文件:

JWS provides many appealing features including, but not limited to, splash screens, desktop integration,file associations, automatic update ..

JWS 提供了许多吸引人的功能,包括但不限于启动画面、桌面集成、文件关联、自动更新......

Other matters

其他事项

..an OS specific way of launching the software.

..一种操作系统特定的软件启动方式。

Adding a shortcut (with icon) to the desktop or start/program menu (desktop integration) is about as platform specific as you can get.

将快捷方式(带图标)添加到桌面或开始/程序菜单(桌面集成)与您可以获得的平台相关。

..will run without Java and offer to install a JRE if not currently present

..将在没有 Java 的情况下运行并提供安装 JRE(如果当前不存在)

Use deployJava.js, linked in the 2ndlast list item under 'See also:'.

使用deployJava.js, 链接在“另请参阅:”下的倒数第二个列表项中。

Well you don't need a separate package per OS if JWS integrates in and looks like a native program.

好吧,如果 JWS 集成并看起来像一个本机程序,则您不需要每个操作系统单独的包。

Using the native PLAF would be a good start.

使用原生 PLAF 将是一个好的开始。

回答by Rohan

Are you looking for something like this:

你在寻找这样的东西:

http://www.regexlab.com/en/jar2exe/

http://www.regexlab.com/en/jar2exe/

?

?

That allows the enduser to run the .exe without installing.

这允许最终用户在不安装的情况下运行 .exe。

回答by Paul Cager

There are a number of options - Java web Start, 3rd party installer, etc.

有许多选项 - Java Web Start、第 3 方安装程序等。

Have a look at http://mindprod.com/jgloss/installer.htmlfor an explanation.

查看http://mindprod.com/jgloss/installer.html以获得解释。

回答by Baltasarq

I think that you're looking for IzPak. There is even a GUI available called PackHymanet

我认为您正在寻找IzPak。甚至还有一个名为PackHymanet的 GUI