Java environment setup

Java environment setup

What is java.library.path

java.library.path is the path that Java uses to find native libraries (such as xyz.dll). We should set it to the directory that contains the DLL files. 

There are  two ways to set java.library.path :
1. We specify this with the -D option on the command line, for example:
  java -Djava.library.path=C:\Java\abcd\libs com.mypckge.MyProgram

 The use of -D option is used to set system property values.


  2. For Windows we can set this path(C:\Java\abcd\libs) in the PATH environment variable. Once set in the environmental variable we will have to restart the system for the changes to take place effectively.

Why do we need to set java.library.path
There are certain cases where an api can refer to native libraries written in other languages. To provide those libraries in the api, we set them in the java.library.path.

The error message can be one of these forms.
can't load lbmj: java.lang.UnsatisfiedLinkError: no lbmj in java.library.path, make sure the directory containing the LBM native libraries is on the path.

Here LBM is a native library being referred in the api.


Comments