Embedding a jre into WInrun4j only once for installer and application

百般思念 提交于 2019-12-25 07:34:00

问题


For installation of my Windows desktop application I create an installer using izpack and then call it from an exe using winrun4j, also part of the izpack installation add another winrun4j wrapper for actually running the application once installed.

The trouble is that for the win4runj.exe to work it needs to be using the correct Java type, i.e if exe is 64bit it must run 64 bit jvm, if exe is 32 bit it must run 32bit jvm. This can be confusing for the user so I was going to take advantage of winrun4j to use an embedded jvm and then make two downloads available

  • widgetinstaller.exe (32-bit)
  • widgetinstaller64.exe (64-bit)

But my confusion is that for each download I only want to embed the jvm once but cannot work out how to do this because i have two exes (the installer, and the program itself) , can this be done ?

Update

Have it working if I install JVM twice (once included in install.jar when built with izpack, and once added to the zip file so can be used by widgetinstaller.exe).

  • widgetinstaller.exe resides in c:\code\widget\installer
  • Download 32bit jre from Oracle
  • Install into c:\code\widget\32bitJVM
  • Edit izpack.xml, adding <file src="C:/code/widget/JVM32bit" targetdir="$INSTALL_PATH"/>
  • Add for installer vm.location=32bitJVM/bin/client/JVM.dll to c:\code\widget\installer\widgetinstaller.ini
  • Add for widget itself vm.location=../32bitJVM/bin/client/JVM.dll to c:\code\widget\widget.ini
  • Rebuild code, and zip up including 32bitJVM in the zip file to create widgetinstaller.zip (this contains 32bitJVM, widgetinstaller.ini,widgetinstaller.exe, widgetinstaller.ico and install.jar)
  • Unzip and double-click on widgetinstaller.exe to install

But I only want JVM once, I know I need to remove the <file src="C:/code/widget/JVM32bit" targetdir="$INSTALL_PATH"/> from izpack.xml, but then how do I copy my 32bitJVM into program installation folder

that same JVM needs to be saved to the program folder.

Seems this has to be done outside of izpack itself ?

EDIT

Solution is to use Izpack loose packs described at at Can I install a file using Izpack 5 without it being part of the install.jar built by izpack

but it is quite confusing what must be set for the path, documentation incorrectly implies you put in a relative link http://izpack.org/documentation/installation-files.html#the-packs-element-packs.

Example

izpack install.xml is in C:\code\Widget\installer

<pack name="Base" loose="true" required="yes" preselected="yes">
   <description>JVM</description>
   <file src="C:\Code\Widget\JVM" targetdir="$INSTALL_PATH"/>
</pack>

When package up izpack installation should have:

JVM
install.jar
setup.exe

回答1:


If the JVM is embedded in the installer then the program cannot use it. And again if the JVM is embedded in the program then the installer cannot use it.

However you can still do it with only one JVM. This is done by coping the JVM to a local file.

So when you launch the installer with the winrun4j it will launch from the embedded JVM, then at the end of the installation, that same JVM needs to be saved to the program folder.

Your program winrun4j exe can then use the JVM that you saved to the folder to launch the program, you do this by setting the "vm.location" in winrun4j to the location of the saved JVM.

Process:
1) Run the installer exe with the required JVM
2) During the installation save the embedded JVM to a file
3) Once the instillation is complete the program exe can launch using the saved JVM


来源:https://stackoverflow.com/questions/12144096/embedding-a-jre-into-winrun4j-only-once-for-installer-and-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!