Java VM 选项:设置相对于项目文件夹的 -Djava.library.path

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27755034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 12:20:00  来源:igfitidea点击:

Java VM Options: Set a -Djava.library.path relative to project folder

javajvm

提问by st.math

I would like to set the -Djava.library.pathVM option to a specific folder. However, it is not relative to my project folder so that I could say for example:

我想将-Djava.library.pathVM 选项设置为特定文件夹。但是,它与我的项目文件夹无关,因此我可以说例如:

-Djava.library.path=native\windows

(The folder nativeis in the project folder.)

(该文件夹母语是在项目文件夹。)

Do you know if this is somehow possible to set it like above and not with -Djava.library.path=C:\...?

你知道这是否有可能像上面那样设置它而不是用-Djava.library.path=C:\...

采纳答案by sorencito

You actually can set a relative path. For example if you start your program a specific folder, you can access libraries in a folder "libs" right next to it by setting the path to "../libs" e.g.

您实际上可以设置相对路径。例如,如果您在特定文件夹中启动程序,则可以通过将路径设置为“../libs”来访问其旁边文件夹“libs”中的库,例如

In my own project with native libraries I have this in my shell script:

在我自己的带有本机库的项目中,我的 shell 脚本中有这个:

-Djava.library.path=../../native/unix

Hope this answers your question.

希望这能回答你的问题。

回答by Danny Daglas

I'm not sure if you are asking how to refer to a relative directory on windows, or how to set this path without the -Djava.library.path=...parameter. So, I will answer both.

我不确定您是问如何在 Windows 上引用相对目录,或者如何在没有-Djava.library.path=...参数的情况下设置此路径。所以,我会回答两个。

To set a relative path, use:

要设置相对路径,请使用:

-Djava.library.path=.\windows

To set this path on Windows without using -D, augment the PATH environment variable:

要在不使用 -D 的情况下在 Windows 上设置此路径,请增加 PATH 环境变量:

setenv PATH %PATH%;C:\path\to\folder

On Linux/Mac, set/augment the LD_LIBRARY_PATH with this folder location.

在 Linux/Mac 上,使用此文件夹位置设置/增强 LD_LIBRARY_PATH。