Include java.exe in runtime

To create an installer for my javafx application, I completed a tutorial . And this, as expected, does the installer.

The directory structure that it creates is as follows:

Myapp

+app +runtime +MyApp.exe +MyApp.ico 

Runtime contains the Java runtime. But the problem is that my application creates some Java process and it needs the java.exe path. But when viewing the above runtime file, it does not contain java.exe.

i.e.

at runtime

 +jre +bin +java.dll missing java.exe 

How to get the path to java.exe so that I can use it to start another java process. Or how to start a java process from java.dll ?

PS: This link discusses the same question, but does not answer it.

+4
source share
1 answer

The โ€œBatch Packaging Cookbook for Fine-Tuning the Application Packageโ€ in the Oracle Java Deployment Team contains instructions on how to configure parts of the JRE to be included in a self-saved application.

I just copy and paste the appropriate section here if the original link does not work:

If you use packaging tools to create an installation package, you may need to customize the application image before it is completed by the installer. What for? For example, you might want to sign an application, so it does not seem unreliable for the OS (for example, to meet the requirements of Mac OS X Gatekeeper).

Also, by default, a stand-alone application does not contain a full copy of Java Runtime. We include only a set of required components. One of the reasons why this approach was taken is that we want to reduce the size of the packet. However, there are situations where your application may depend on these optional components, in which case you will need a way to add them to your private runtime. For example, https connections will not work if jre / lib / ext / sunjce_provider.jar is missing.

Currently, this can be achieved by providing a custom script configuration that runs after the application image is populated. As in the icon example above, you need to enable verbose output to find the script file name, and then drop it to the place where the packaging tools are found. Please note that the scripting language is also platform dependent. Currently, we only support the shell for Mac / Linux and the Windows script on Windows.

How do you know where the application image is located? Currently, user scripts are run in the directory where the configuration files are stored, but access to the application images can be obtained using the relative path to a specific platform. You can infer this path from verbose output, or by setting the JAVAFX_ANT_DEBUG environment variable to true to save intermediate build artifacts.

Here is an example script (contributed by John Petersen) that you can use to add jre / lib / ext / sunjce_provider.jar to the Windows MyApp application package. script using Javascript, but you can also use VBScript scripts for Windows.

 <?xml version="1.0" ?> <package> <job id="postImage"> <script language="JScript"> <![CDATA[ var oFSO = new ActiveXObject("Scripting.FileSystemObject"); var oFolder = oFSO.getFolder("."); var from = oFolder.path + "\\MyApp\\app\\sunjce_provider.jar"; var to = oFolder.path + "\\MyApp\\runtime\\jre\\lib\\ext"; if (!oFSO.FolderExists(to)) { oFSO.CreateFolder(to); } to += "\\"; oFSO.CopyFile(from, to); ]]> </script> </job> </package> 

In the discussion above, the sunjce_provider.jar file is sunjce_provider.jar from the JRE installation to the application package, but the procedure for copying any other file, including java.exe , should be similar.

For more information on how to create a custom package initially, see the JavaFX Deployment Guide .

+2
source

Source: https://habr.com/ru/post/1481937/


All Articles