Home » Java programming language

Java System class loadLibrary() method with example

System class loadLibrary() method: Here, we are going to learn about the loadLibrary() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 15, 2019

System class loadLibrary() method

  • loadLibrary() method is available in java.lang package.
  • loadLibrary() method is used to load the library with the given parameter named library_name(library name) as an argument passed in the method.
  • A java file may contain native code for that we need to load the library by using loadLibrary() method. In this method, the mapping from a library_name to a given file name is done in a system-specific manner. At the time of class loading and instantiating, the required implemented native code for the native methods will then be loaded as well.
  • loadLibrary() method is a static method, it is accessible with the class name too.
  • loadLibrary() method may throw an exception at the time of library loading:
    • SecurityException: In this exception, its checkLink() method does not allow load the specified library as passed in the method when the security manager exists.
    • UnsatisfiedLinkError: In this exception, if the loaded library does not exists.
    • NullPointerException: In this exception, if the loaded library is null.


    public static void loadLibrary(String library_name);


  • String library_name – represents the name of the library.

Return value:

The return type of this method is void, it does not return anything.


// Java program to demonstrate the example of 
// loadLibrary() method of System Class

public class LoadLibraryMethod {
    public static void main(String[] args) {
        // load a library FP30TXT.dll that is in Windows/system folder*/
        System.out.println(" Process of Library Loading ");
        System.out.println("Process of Library Loading  completion");


E:\Programs>javac LoadLibraryMethod.java
E:\Programs>java LoadLibraryMethod
Process of Library Loading
Process of Library Loading completion

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.