可执行Jar安装路径
对于清单中包含主类的可执行 Jar:
当我使用 java -jar myjar.jar 启动它时,如何在运行时找到此 jar 的安装目录?
我想要做什么正在为 Flyway 开发命令行客户端。
该工具将使用以下文件夹结构进行安装:
INSTALLATION_PATH
|
-- bin
| |
| --start.sh (launches flyway.jar)
|
-- lib
| |
| --flyway.jar (contains Main class, loads flyway.properties)
|
-- conf
|
--flyway.properties (configuration)
flyway.jar 如何解析 INSTALLATION_PATH?
For an executable Jar with a Main Class in the Manifest:
When I launch it using java -jar myjar.jar , how can I find out the installation directory of this jar at runtime?
What I want to do is develop a command-line client for Flyway.
The tool will be installed with the following folder structure:
INSTALLATION_PATH
|
-- bin
| |
| --start.sh (launches flyway.jar)
|
-- lib
| |
| --flyway.jar (contains Main class, loads flyway.properties)
|
-- conf
|
--flyway.properties (configuration)
How can flyway.jar resolve INSTALLATION_PATH?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试:
You can try :
以下将为您提供起始目录:
the following will give you the starting directory:
执行此操作的首选方法是:
进行安装,然后编辑系统类路径属性以添加此 jar 和任何依赖的 jar。
之后,您可以从任何目录运行它。
当然,这样做的好处是,您只需在安装时设置一次类路径。每次决定运行它时,无需在运行时查找安装目录。
A preferred way of doing this instead of trying to find out the installation directory at runtime is this:
Do the install, and then edit the system classpath properties to add this jar and any dependant jars.
After that, you can run it from any directory.
The benefit is of course that this way , you set the classpath only once at installation time. No need to find installation directory at runtime every time you decide to run it.