(MAC OS X)
How to Load a Java Native/Shared Library (.jnilib)
There are several ways to make it possible for the Java runtime to find and load a native shared library (.jnilib) at runtime. I will list them briefly here, followed by examples with more explanation below.
- Call System.load to load the .jnilib from an explicitly specified absolute path.
- Copy the shared library to one of the paths already listed in java.library.path
- Modify the LD_LIBRARY_PATH environment variable to include the directory where the shared library is located.
- Specify the java.library.path on the command line by using the -D option.
- Put the .jnilib in /Library/Java/Extensions/.
How can DYLDLIBRARYPATH be unset for launchd processes? Ask Question. Did you try to set DYLDLIBRARYPATH to /opt/local/lib:/usr/lib in your launcher (in the EnvironmentVariables section). Browse other questions tagged osx apache-httpd php or ask your own question.
A note about DYLDLIBRARYPATH and other DYLD environment variables. On OSX, the library search path is set primarily by the environment variable DYLDLIBRARYPATH (and the few other DYLD. variables). Because of the way the OSX dynamic library loader works, this variable works differently than the LDLIBRARYPATH on Linux. This document is a Mac OS X manual page. Manual pages are a command-line technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles.
1. Call System.load to load the shared library from an explicitly specified absolute path.
This choice removes all uncertainty, but embeds a hard-coded path within your Java application. Example:
2. Copy the shared library to one of the paths already listed in java.library.path
To view the paths listed in java.library.path, run this Java code:
Note: The java.library.path is initialized from the LD_LIBRARY_PATH environment variable.
The loadLibrary method may be used when the directory containing the shared library is in java.library.path. To load 'libchilkat.jnilib', call System.loadLibrary('chilkat'), as shown below.
3. Modify the LD_LIBRARY_PATH environment variable to include the path where the Chilkat shared library is located.
For Bourne Shell, K Shell or Bash, type:
For C Shell, type:
4. Specify the java.library.path on the command line by using the -D option.
For example:
Additional Notes:
From developer.apple.com: 'JNI libraries are named with the library name used in the System.loadLibrary() method of your Java code, prefixed by lib and suffixed with .jnilib. For example, System.loadLibrary('hello') loads the library named libhello.jnilib. Java HotSpot also recognizes .dylib as a valid JNI library format as of Mac OS X v10.5.'
Check your PATH Setting
Macos Set Library Path
In the instructions below, $INSTALL_DIR refers to the path to the new install directory, /path/to/dakota/install/directory/Dakota.
Make sure Dakota executables (and optionally test files and current directory) are available on the PATH by typing 'which dakota' at command line prompt. If your PATH variable is set correctly, the path to the dakota binary should be displayed.
If your PATH variable is NOT set correctly, you will get a message like the following:
The following setup will make the dakota command and other helper programs available at the terminal. If you prefer you may refer to the dakota executable using its fully-qualified path. Note, however, that some examples will require modification to work properly if dakota and related helper programs are not on your PATH.
To persist the PATH to Dakota across terminals/sessions, make the following changes to the appropriate shell login script. If you prefer to just test in your current terminal, execute the commands directly in a terminal.
Make Changes in Bash Shell
- Edit your Bash startup file in your favorite text editor. For Linux, this is ~/.bashrc. OS X terminal runs a login shell, and so the start up file may be ~/.bashrc, ~/.bash_profile, ~/.bash_login, or ~/.profile. See the manpage for Bash for more information about the differences between login and non-login shells.
- Modify and export PATH, PYTHONPATH, and (if using a Dakota release prior to 6.8) (DY)LD_LIBRARY_PATH variables. Type the following line, replacing $INSTALL_DIR with the absolute path to your installation directory, e.g. $HOME. You need not add the gui path if you are not using the Dakota GUI, or PYTHONPATH if you do not plan to use the dakota.interfacing Python module.
On Linux:
On OS X:
- Save and close file.
- Update changes in your shell window.
Mac Os X Set Library_path 2017
Make Changes in C shell
Mac Os X Set Library_path 2
- Edit the startup file ~/.cshrc in your favorite text editor.
- Modify and export PATH, PYTHONPATH, and (if using a Dakota release prior to 6.8) (DY)LD_LIBRARY_PATH variables. Type the following line, replacing $INSTALL_DIR with the absolute path to your installation directory, e.g. $HOME. You need not add the gui path if you are not using the Dakota GUI, or PYTHONPATH if you do not plan to use the dakota.interfacing Python module.
On Linux:
On OS X:
- Save and close file.
- Update changes in your shell window.