简体   繁体   English

如何从install4j中的脚本访问sys.preferredJre?

[英]How to access sys.preferredJre from a script in install4j?

My application uses authentication through a LDAP server over SSL. 我的应用程序通过SSL上的LDAP服务器使用身份验证。 This requires installation of certificates in the bundled JRE's keystore. 这需要在捆绑的JRE的密钥库中安装证书。 I use a script to do it through Java code and in the process need to find the location of the installed JRE. 我使用脚本通过Java代码来完成此任务,并且在此过程中需要查找已安装JRE的位置。 This script is executed at the end of the installation. 该脚本在安装结束时执行。

On Windows, it's relatively simple: I just use context.getInstallationDirectory() and then add jre\\lib\\security\\cacerts . 在Windows上,这相对简单:我只使用context.getInstallationDirectory() ,然后添加jre\\lib\\security\\cacerts

On Mac OS, however, the JRE is installed in a different location and I would need to use the actual sys.preferredJre or the java.home property. 但是,在Mac OS上,JRE安装在其他位置,我需要使用实际的sys.preferredJrejava.home属性。 The problem is that I can't access them from the scripts. 问题是我无法从脚本访问它们。 The context object doesn't seem to have the corresponding methods. 上下文对象似乎没有相应的方法。 System.getProperty("java.home") returns a temporary location where the JRE is probably first unpacked and not the final path. System.getProperty("java.home")返回一个临时位置,该位置JRE可能首先被解压缩,而不是最终路径。 context.getCompilerVariable("sys.preferredJre") returns null. context.getCompilerVariable("sys.preferredJre")返回null。

As a side note, there doesn't seem to be any logging from inside the scripts. 附带说明一下,脚本内部似乎没有任何日志记录。 All I get is a brief message about the script succeeding or failing. 我得到的只是关于脚本成功或失败的简短消息。 I had to write to a custom file to get any information. 我必须写一个自定义文件以获取任何信息。

Can you suggest a way to handle this? 您能建议一种解决方法吗? Ideally, I would like to do it in OS-independent way and just get the Jre directory. 理想情况下,我想以与操作系统无关的方式进行操作,只是获取Jre目录。

Thanks in advance 提前致谢

Sasha 萨沙

After the "Install files" action has run, the sys.preferredJre installer variable is set to the directory where the bundled JRE has been installed. 运行“安装文件”操作后, sys.preferredJre安装程序变量设置为已安装捆绑JRE的目录。 You can get this variable by calling 您可以通过调用此变量

context.getVariable("sys.preferredJre")

In your question, you use getCompilerVariable , which is not correct because it returns values of compiler variables. 在您的问题中,您使用了getCompilerVariable ,这是不正确的,因为它返回编译器变量的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM