How to specify LD_LIBRARY_PATH (or PATH) for each project in Netbeans?

To load .DLL (for Windows) or .SOs (for Linux), we must use the PATH (Windows) or LD_LIBRARY_PATH (Linux) environment variables.

The only way we could find the correct use of the DLL and SO is to define the environment variables before starting Netbeans.

  • Is there a way to specify these environment variables inside Netbeans?
  • Is it possible to specify it inside a property project? Thus, each project can have its own definitions.
  • Is there a way to simply add environment variables to these variables instead of simply overriding them?

Background: We are developing a Java program that uses JNI to access native libraries. Those native libraries, in turn, gain access to other dependent native libraries. Because of this, simply setting the "java.library.path" property does not work, since we also need to set the full LD_LIBRARY_PATH (or the usual PATH in the case of Windows).

The external Netbeans application works fine because we set environment variables inside shell scripts.

We don’t want to just put DLLs or SO libraries in regular system directories, because we don’t want to spoil the installation of the operating system during development. In addition, we want to have the flexibility so that any developer can simply get the project from a control source (Mercurial) and have all the relative paths that just work.

There is already a hacked stack overflow so that program environment variables are programmatically displayed in Java . However, we are looking for a less hacky solution.

+4
source share
1 answer

You can override the Ant script tasks that NetBeans uses in the build.xml file (or edit them directly in the full script in nbproject/build-impl.xml , but not recommended).

The java task is used in run target. You can use the env parameter to specify environment variables for the process that will run the JVM.

0
source

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


All Articles