java 如何为izpack安装程序.jar文件制作.exe文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5646813/
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
How to make .exe file for izpack installer .jar file
提问by Muhammad Imran Tariq
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?
我用izpack制作了一个安装程序。它在 .jar 文件中。我想在 .exe 文件中制作它以便分发它。我怎样才能以简单的方式做到这一点?
回答by eee
Andrew always likes to promote Java Web Starttechnology 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.
Andrew从一开始就喜欢推广Java Web Start技术 :) 这是一项不错的技术。但是,您还需要先学习技术部分,然后才能开始修补它。
Otherwise, you are left with the old-style EXE distribution model as follows...
否则,您将使用旧式 EXE 分发模型,如下所示...
I am not familiar with Izpackanyway. But, there are similar separate tools to achieve the combined result as to what izPackcan do. My favorite EXE creation and installer tools are Launch4J+ InnoSetup+ Ant taskrunning from Eclipse IDE.
反正我对Izpack不熟悉。但是,对于izPack可以做什么,有类似的单独工具来实现组合结果。我最喜欢的 EXE 创建和安装程序工具是从Eclipse IDE运行的Launch4J+ InnoSetup+ Ant 任务。
Launch4Jis a Java app launcher. InnoSetupis an installation creator Ant taskhelps developers on build and integration steps.
Launch4J是一个 Java 应用程序启动器。 InnoSetup是一个安装创建者 Ant 任务,可帮助开发人员进行构建和集成步骤。
How to use Launch4J + InnoSetup + Ant build task + Eclipse IDE: http://www.eteks.com/tips/tipCreationExe.html(in French - use Google translate)
如何使用 Launch4J + InnoSetup + Ant 构建任务 + Eclipse IDE:http: //www.eteks.com/tips/tipCreationExe.html(法语 - 使用谷歌翻译)
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.
当您考虑为 Java 应用程序分发基于桌面的 Windows EXE 文件时,您还需要考虑目标环境。当您的目标是 Windows XP 或更低版本时,这很好。但是,当你想让它在 Windows Vista 和 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-onlyfolder. Use user's profile folder for such purpose.
%ProgramFiles%
在 Windows Vista/Windows 7 下,最好不要存储需要保存的应用程序配置、临时文件等,因为它现在变成了只读文件夹。为此目的使用用户的配置文件文件夹。
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 enableRun as administrator
. A shortcut shall be created in the Desktop and be set to enableRun as administrator
as well.
Windows Vista 和 Windows 7 通过用户访问控制 (UAC) 提示功能引入了严格的用户访问策略。必须使用管理员组下的用户帐户完成软件安装。默认 Windows 系统下的所有文件夹
Program Files
都设置为只读,当尝试在其中保存内容时,可能会导致非管理员用户帐户出现问题。要使用非管理员用户帐户运行 Java 应用程序,必须将应用程序属性设置为 enableRun as administrator
。应在桌面中创建一个快捷方式并设置为启用Run as administrator
。
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
(1) AppUserModelID
Windows Vista/Windows 7 中的 Java 支持问题需要以下解决方案:Launch4j、NSIS 和重复的固定 Windows 7 任务栏图标
(2) Issue with Run as Administrator
for a Java app needs the following solution:Request admin privileges for Java app on Windows Vista
(2) Run as Administrator
Java 应用程序的问题需要以下解决方案:在 Windows Vista 上请求 Java 应用程序的管理员权限
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)%
.
除此之外,%ProgramFiles%
在 64 位 Windows 版本下运行时还需要检查。32 位 Windows 和 64 位 Windows 之间的路径不同。在 64 位 Windows 下,所有 32 位应用程序都将进入%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 InnoSetupin the following ISS file snippet. Use Java System.getenv("MYAPP_HOME")
to retrieve the variable:
因此,在将硬编码文件路径值用于 Java 应用程序的文件夹和安装在%ProgramFiles%
. 最好设置一个Windows environment variable
可以由InnoSetup在以下 ISS 文件片段中生成的。使用 JavaSystem.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"
Experiment and enjoy!
实验并享受!
回答by Paul Taylor
回答by Andrew Thompson
If the app. has a GUI and you can distribute from a web site, Java Web Startoffers the best solution. JWS works for all platforms that support Java, and is supported by Oracle.
如果应用程序。有一个 GUI 并且您可以从网站分发,Java Web Start提供了最好的解决方案。JWS 适用于所有支持 Java 的平台,并且受 Oracle 支持。
(I hear that .Net works well for 'Windows only' solutions.)
(我听说 .Net 适用于“仅限 Windows”的解决方案。)