NetBeans 和 Inno Setup 不会生成正确的 Native .exe [英] NetBeans and Inno Setup don't produce a proper Native .exe

查看:20
本文介绍了NetBeans 和 Inno Setup 不会生成正确的 Native .exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Netbeans 中创建了一个 JavaSE 应用程序,并且正在使用 Inno Setup 5 生成我认为是完整的 Windows 安装,包括 JRE.按照指示,我已经检查了本机的 NetBeans 属性框,并且在路径中有 Inno Setup 5.EXE 生成并很好地安装,前提是目标机器安装了 Java.如果不是,则没有与 .jre 和 javac.exe 的文件关联,因此 .jar 文件将不会运行.

I've created a JavaSE app in Netbeans and am using Inno Setup 5 to generate what I thought was a complete Windows installation, including JRE. As instructed, I have checked the NetBeans property boxbox for Native, and have Inno Setup 5 in the Path. The EXE is generated and installs nicely PROVIDED the target machine has Java installed. If it doesn't, there's no file association with .jre and no javac.exe so the .jar file won't run.

3/4/2017:经过今天的大量探索和尝试,我现在更全面地了解 NetBeans Native 打包真正在做什么.它会创建一个安装程序 exe,当它传输到带有或不带有 JRE 的目标机器上并在其上执行时,会创建实际的 myApp.exe 并将其放在开始"菜单上.我的问题一直认为 myApp.jar 文件中包含 JRE,所以我只是想双击 myApp.jar.如果我使用 myApp.exe 它可以工作.

3/4/2017: After lots of poking around and trying things today I now understand more fully what NetBeans Native packaging is really doing. It creates an Installer exe that, when transferred to and executed on a target machine with or without JRE, creates the actual myApp.exe and puts it on the Start menu. My problem has been thinking the myApp.jar file had the JRE in it, so I was just trying to double-click the myApp.jar. If I use the myApp.exe it works.

但是,我现在发现我仍然有问题.myApp 需要许多支持数据文件并从 .ini 文件中读取.因此,我将不得不创建一个 Inno 安装程序来单独执行这些操作,我的用户将不得不下载并运行两个安装程序,可以这么说.如果执行 NetBeans Native 安装程序的人让 Inno 安装文件可供编辑,那就太好了.

However, I now see I still have a problem. myApp requires a number of supporting data files and reading from an .ini file. Consequently, I'm going to have to create an Inno setup to do that stuff separately, and my users will have to download and run TWO installers, so to speak. Had the person who did the NetBeans Native installer thing made the Inno setup file accessible for editing, that would be neat.

埃德

推荐答案

NetBeans 具有用于创建本机"应用程序的打包选项,即用于 Windows 的 MyApp.exe 文件.这样做的重要性在于您获得了一个包含 JRE 的 Windows 可执行文件,这意味着最终用户不需要在他/她的机器上安装 Java 或 JRE 来运行应用程序.

NetBeans has a Packaging option for creating a "Native" application, i.e., a MyApp.exe file for Windows. The importance of this is you get a Windows executable the INCLUDES JRE, meaning that the ultimate user doesn't need to install Java or JRE on his/her machine to run the application.

这听起来很棒,但是文档并不清楚如何使它工作,至少对我来说不是.这是我学到的东西.

This sounds wonderful, but the documentation is not at all clear about how to make it work, at least not to me. Here's what I've learned.

首先,要使其工作,您必须在开发计算机上安装 Inno Setup 5 或更高版本.显然,NetBeans 创建了一个 Inno .iss 文件并运行它.

First, for this to work you have to have Inno Setup 5 or higher installed on you development computer. Apparently, NetBeans creates an Inno .iss file and runs it.

为了更好地理解它,我为 Inno AnagramGame 示例制作了一个 NetBeans 项目.要启用本机打包选项,首先选择 NetBeans 中的项目,右键单击并选择 Properties|Deployment.检查原生包装盒.这会导致 EXE 选项放置在 NetBeans 打包菜单上.即,选择项目,右键单击并单击打包为.单击 EXE 安装程序启动构建包"的过程.

To understand it better I made a NetBeans projects for the Inno AnagramGame example. To enable the Native packaging option, first select the Project in NetBeans , right-click and select Properties|Deployment. Check the Native packaging box. This causes the EXE option to be placed on the NetBeans Packaging menu. I.e., Select the Project, right-click and click on Package As. Clicking EXE Installer launches the process of building the "package."

构建安装程序需要很长时间,因为它必须积累所有必要的 JRE 部分并将其合并到包中.这也使安装程序变大.即使对于最小的 Java 程序,它也将是大约 35 Mb.

Building the installer takes a LONG time because it has to accumulate all the necessary pieces of the JRE and incorporate into the package. This also makes the installer BIG. Even for the smallest Java program it will be about 35 Mb.

一些应用程序的 Native 打包后,例如 AnagramGame2,您会在 NetBeans 项目文件夹中找到以下内容:C:UsersEd SowellDocumentsNetBeansProjectsAnagramGame2distanagrams.jar和C:UsersEd SowellDocumentsNetBeansProjectsAnagramGame2distundlesAnagramGame2-1.0.exe

After the Native packaging of some app, for example AnagramGame2, you will find the following in the NetBeans project folder: C:UsersEd SowellDocumentsNetBeansProjectsAnagramGame2distanagrams.jar and C:UsersEd SowellDocumentsNetBeansProjectsAnagramGame2distundlesAnagramGame2-1.0.exe

Anagrams.jar 是 AnagramGame2 应用程序的 Java 存档文件.如果您已经安装了 JAVA,这将通过双击实际运行该项目.但是,如果您将其移动到另一台未安装 Java 或 JRE 的计算机,它将无法执行.原因是 jar 文件没有包含 JRE.我花了很长时间才意识到这一点.

Anagrams.jar is the Java archive file for the AnagramGame2 app. IF YOU HAVE JAVA INSTALLED, this will actually run the project by double clicking. However, if you move it to another computer WITHOUT Java or JRE installed, it will not be executable. The reason is the jar file does NOT incorporate the JRE. It took me long time to recognize this.

现在,您可能认为 AnagramGame2-1.0.exe 是该应用程序的本机可执行文件,但不,它不是.它实际上是安装程序,另一个让我花了很长时间才认出来的东西.

Now, you might be thinking AnagramGame2-1.0.exe is the Native executable for the app but, nay, it is not. It is in fact the installer, another thing that took me a long time to recognize.

那么,传说中的 Windows Native 应用程序文件在哪里?答案是它还无处可去.为了得到它,你必须运行安装程序!运行它后,你会在所有地方找到非常想要的 EXE,C:UsersEd SowellAppDataLocalAnagramGame2:

So, where is the fabled Windows Native app file? The answer is it is nowhere, yet. In order to get it YOU MUST RUN THE INSTALLER! After running it you will find the much wanted EXE in, of all places, C:UsersEd SowellAppDataLocalAnagramGame2:

C:UsersEd SowellAppDataLocalAnagramGame2AnagramGame2.exe

C:UsersEd SowellAppDataLocalAnagramGame2AnagramGame2.exe

此外,选择适当的选项后,应用名称将显示在 Windows 的开始"菜单和桌面上.

Also, with the appropriate options selected, the app name will appear on the Windows Start menu and desktop.

因此,要分发 Windows Native 应用程序,您必须:

So, to distribute the Windows Native application you have to:

  1. 创建一个 NetBeans 项目.
  2. 对项目进行干净的构建
  3. 为项目启用本地打包选项
  4. 作为|本地安装程序做一个包
  5. 分发安装程序,在本例中为 AnagramGame2-1.0.exe
  6. 然后您的用户运行安装程序.然后,他/她从开始"菜单或双击桌面图标运行应用程序.

关于正确使用这个 NetBeans/Inno Setup 过程,我还有很多不明白的地方.有一些小谜团,例如为什么它在 User AppData Local 中隐藏了最终产品的位置.谁会想到去那里看?为什么它调用安装程序 AnagramGame2-1.0.exe 而不是 setupAnagramGame2.exe 之类的东西?但这是我尚未解决的最大问题:如何安装应用程序所需的辅助文件?或者从 INI 文件中获取所需的数据?如果在 NetBeans 进程中构建和使用的 .iss 可用,则可以对其进行编辑,但到目前为止我还没有找到它.我的猜测是它被删除了.除此之外,我唯一能想到的就是编写另一个 .iss 文件来完成这项工作.不幸的是,这意味着用户必须下载并运行两个安装程序!

There's still a lot I don't understand about the proper use of this NetBeans/Inno Setup process. There are some small mysteries, such as why it hides the location of the end product in User AppData Local. Who would have thought to look there? And why does it call the Installer AnagramGame2-1.0.exe instead of something like setupAnagramGame2.exe? But here's the biggest problem I've yet to solve: How does one install ancillary files needed by the app? Or get needed data out of an INI file? If the .iss that is built and used in the NetBeans process were made available it could be edited, but so far I've not been able to find it. My guess is it gets deleted. Short of that, the only thing I can think of is to write another .iss file to do that work. Unfortunately than means the user has to download and run two installers!

这篇关于NetBeans 和 Inno Setup 不会生成正确的 Native .exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆