如何为 izpack 安装程序 .jar 文件制作 .exe 文件

发布于 2024-10-31 16:15:25 字数 94 浏览 1 评论 0原文

我用 izpack 制作了一个安装程序。它在 .jar 文件中。我想将其制作为 .exe 文件以便分发它。我怎样才能以简单的方式做到这一点?

I make an installer with izpack. Its in .jar file. I want to make it in .exe file in order to distribute it. How can I do it in an easy way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原野 2024-11-07 16:15:25

Andrew 总是喜欢从一开始就推广 Java Web Start 技术:) 这是一项很好的技术。但是,您还需要先学习技术部分,然后才能开始修补它。

否则,您将使用旧式 EXE 分发模型,如下所示...

无论如何我都不熟悉 Izpack。但是,有类似的单独工具可以实现 izPack 的综合结果。我最喜欢的 EXE 创建和安装工具是从 Eclipse IDE 运行的 Launch4J + InnoSetup + Ant 任务

Launch4J 是一个 Java 应用程序启动器。
InnoSetup 是一个安装创建者
Ant 任务 帮助开发人员完成构建和集成步骤。

如何使用Launch4J + InnoSetup + Ant构建任务+ Eclipse IDE
http://www.eteks.com/tips/tipCreationExe.html(法语- 使用 Google 翻译)

当您考虑为 Java 应用程序分发基于桌面的 Windows EXE 文件时,您还需要考虑目标环境。当您的目标是 Windows XP 或更低版本时,这没问题。但是,当您想让它在 Windows Vista 和 Windows 7 下正常工作时,这将开始成为一个重大挫折。

最好不要将需要保存到 %ProgramFiles%< 的应用程序配置、临时文件等存储/code> 在 Windows Vista/Windows 7 下,因为它现在成为只读文件夹。为此目的使用用户的配置文件文件夹。

当然,您可以通过使用“以管理员身份运行”运行应用程序来绕过它,但它涉及以下设置:

Windows Vista 和 Windows 7 有
引入了严格的用户访问策略
通过用户访问控制(UAC)
提示功能。软件
安装必须使用用户完成
管理员组下的帐户。
默认Windows下的所有文件夹
系统程序文件设置为
只读,这可能会导致问题
到非管理员用户帐户
当尝试在其中保存某些内容时。使用以下命令运行 Java 应用程序
非管理员用户帐户,
应用程序属性必须设置为
启用以管理员身份运行。一个
快捷方式应创建在
桌面并设置为启用运行方式
管理员也是如此。


如何解决以下问题:

(1) Windows Vista/Windows 7 中的 AppUserModelID Java 支持问题需要以下解决方案:
Launch4j、NSIS 和重复的固定 Windows 7 任务栏Icons

(2) Java 应用程序的以管理员身份运行 问题需要以下解决方案:
请求 Windows Vista 上的 Java 应用程序的管理员权限

其他除此之外,在 64 位 Windows 版本下运行时还需要检查 %ProgramFiles%。 32 位 Windows 和 64 位 Windows 之间的路径不同。在 64 位 Windows 下,所有 32 位应用程序都将进入 %ProgramFiles(x86)%

因此,在使用 %ProgramFiles% 中安装的 Java 应用文件夹和子文件夹的硬编码文件路径值时要小心。最好设置一个 Windows 环境变量,该变量可以由以下 ISS 文件片段中的 InnoSetup 生成。使用 Java System.getenv("MYAPP_HOME") 检索变量:

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; Flags: uninsdeletevalue; ValueType: string; ValueName: "MYAPP_HOME"; ValueData: "{app}\"

[Tasks]
Name: modifypath; Description:"Add application directory to your environmental path"; Flags: unchecked

[Run]
Filename: "{app}\MyApp.EXE"; Parameters: """{app}""\"; WorkingDir: "{app}\"; Description: "Run MyApp"; Flags: postinstall nowait skipifsilent

[Code]

const
    ModPathName = 'modifypath';
    ModPathType = 'system';

function ModPathDir(): TArrayOfString;
begin
    setArrayLength(Result, 1)
    Result[0] := ExpandConstant('{app}');
end;
#include "modpath.iss"

实验并享受!

Andrew always likes to promote Java Web Start technology from the start :) It is a nice tech. But, you also need to learn the technical parts first before you can start tinkering with it.

Otherwise, you are left with the old-style EXE distribution model as follows...

I am not familiar with Izpack anyway. But, there are similar separate tools to achieve the combined result as to what izPack can do. My favorite EXE creation and installer tools are Launch4J + InnoSetup + Ant task running from Eclipse IDE.

Launch4J is a Java app launcher.
InnoSetup is an installation creator
Ant task helps developers on build and integration steps.

How to use Launch4J + InnoSetup + Ant build task + Eclipse IDE:
http://www.eteks.com/tips/tipCreationExe.html (in French - use Google translate)

When you are thinking of distributing a desktop-based Windows EXE file for a Java app, you also need to think about the target environment. It is fine when you are targeting Windows XP or lesser version. But, it will start to be a major frustration when you want to make it work properly under Windows Vista and Windows 7.

It is best not to store application configurations, temporary files, etc. that require saving into%ProgramFiles% under Windows Vista/Windows 7 as it now becomes a read-only folder. Use user's profile folder for such purpose.

Of course, you can bypass it by running your app with "Run as Administrator" but it involves the following setup:

Windows Vista and Windows 7 have
introduced a strict user access policy
through the User Access Control (UAC)
prompt feature. The software
installation must be done using a user
account under Administrators group.
All folders under the default Windows’
system Program Files are set to
read-only and it may cause a problem
to non-administrator user accounts
when trying to save something in it. To run Java app using a
non-administrator user account, the
application properties must be set to
enable Run as administrator. A
shortcut shall be created in the
Desktop and be set to enable Run as
administrator
as well.

How to solve the following issues:

(1) Issue with AppUserModelID Java support in Windows Vista/Windows 7 needs the following solution:
Launch4j, NSIS, and duplicate pinned Windows 7 taskbar icons

(2) Issue with Run as Administrator for a Java app needs the following solution:
Request admin privileges for Java app on Windows Vista

Other than those, you also need to check on %ProgramFiles% when running under 64-bit Windows version. The path is not the same between 32-bit Windows and 64-bit Windows. Under 64-bit Windows, all 32-bit apps will go into %ProgramFiles(x86)%.

So, be careful when using the hard-coded file path value to your Java app's folder and sub-folders that are installed in %ProgramFiles%. It is better to set up a Windows environment variable which can be generated by InnoSetup in the following ISS file snippet. Use Java System.getenv("MYAPP_HOME") to retrieve the variable:

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; Flags: uninsdeletevalue; ValueType: string; ValueName: "MYAPP_HOME"; ValueData: "{app}\"

[Tasks]
Name: modifypath; Description:"Add application directory to your environmental path"; Flags: unchecked

[Run]
Filename: "{app}\MyApp.EXE"; Parameters: """{app}""\"; WorkingDir: "{app}\"; Description: "Run MyApp"; Flags: postinstall nowait skipifsilent

[Code]

const
    ModPathName = 'modifypath';
    ModPathType = 'system';

function ModPathDir(): TArrayOfString;
begin
    setArrayLength(Result, 1)
    Result[0] := ExpandConstant('{app}');
end;
#include "modpath.iss"

Experiment and enjoy!

秋日私语 2024-11-07 16:15:25

如果应用程序。有一个 GUI,您可以从网站进行分发,Java Web Start 提供了最佳解决方案。 JWS 适用于所有支持 Java 的平台,并受 Oracle 支持。

(我听说 .Net 对于“仅限 Windows”的解决方案效果很好。)

If the app. has a GUI and you can distribute from a web site, Java Web Start offers the best solution. JWS works for all platforms that support Java, and is supported by Oracle.

(I hear that .Net works well for 'Windows only' solutions.)

很酷又爱笑 2024-11-07 16:15:25

winrun4j 非常容易使用,我唯一的问题是,除非你使用嵌入式 JVM 进行分发,否则你'您可能需要同时提供 64 位和 32 位下载。

winrun4j is very easy to use, my only issue with it is that unless you are distributing with an embedded JVM you'll probably have to provide both a 64bit and a 32bit download.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文