使用launch4j时如何获取可执行文件的路径? [英] How to get the path to the executable when using launch4j?

查看:178
本文介绍了使用launch4j时如何获取可执行文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用launch4j在我的Windows应用程序中包装一个可执行jar文件,但是我需要通过JVM参数传递对它的一些库的引用。有问题的库位于应用程序安装目录中,并且总是位于相对于可执行文件的相同位置。

I'm using launch4j to wrap an executable jar file in my Windows application, but I need to pass references to some of its libraries in through the JVM arguments. The libraries in question reside in the application install directory, and are always located in the same place, relative to the executable.

我想告诉launch4j使用可执行文件JVM选项中的相对路径。我知道这些信息可以在Windows批处理脚本级别获得,但是如何配置launch4j来获取它?

I'd like to tell launch4j to use executable-relative paths in the JVM options. I know this information is available at the Windows batch script level, but how do you configure launch4j to fetch it?

编辑以澄清:我我正在寻找如何使路径相对于二进制本身,如何使它们相对于当前工作目录。两者不一定相同。

Edit for clarification: I'm looking specifically for how to make the paths relative to the binary itself, not how to make them relative to the current working directory. The two aren't necessarily the same.

推荐答案

您可以添加到launch4j配置

You might add to your launch4j configuration

...
<jre>
...
<opt>-Djna.library.path="%EXEDIR%\\path\\to\\lib"</opt>
<opt>-Djava.library.path="%EXEDIR%\\path\\to\\lib"</opt>
...
</jre>
...

如果你需要更多,那么你可以用semikolon分隔几条路径像往常一样。

If you need more then a you might seperate several paths by a semikolon as usual.


< opt>可选,接受您通常传递给
java / javaw launcher的所有内容:断言选项,系统属性和X
选项。在这里,您可以将环境和特殊变量EXEDIR
(exe的运行时目录),EXEFILE(exe的运行时完整文件路径)映射到
系统属性。所有变量引用必须用
百分比符号包围并引用。

< opt> Optional, accepts everything you would normally pass to java/javaw launcher: assertion options, system properties and X options. Here you can map environment and special variables EXEDIR (exe's runtime directory), EXEFILE (exe's runtime full file path) to system properties. All variable references must be surrounded with percentage signs and quoted.

来源: http://launch4j.sourceforge.net/docs.html

这篇关于使用launch4j时如何获取可执行文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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