Java virtual machine options: set the -Djava.library.path parameter relative to the project folder

I would like to set the -Djava.library.path VM option to a specific folder. However, this does not apply to my project folder, so that I can, for example, say

 -Djava.library.path=native\windows 

( native is a folder in the same directory as src, etc.).

Do you know that it is possible how to install above and not using -Djava.library.path=C:\... ?

+5
source share
2 answers

In fact, you can set the relative path. For example, if you run your program in a specific folder, you can access the libraries in the "libs" folder next to it by setting the path to "../libs", for example.

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

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

Hope this answers your question.

+3
source

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

To set the relative path, use:

 -Djava.library.path=.\windows 

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

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

On Linux / Mac, install / add LD_LIBRARY_PATH with this folder.

0
source

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


All Articles