A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/java/lang/system_load.htm below:

Java System load() Method

Java System load() Method Description

The Java System load() method loads a code file with the specified filename from the local file system as a dynamic library. The filename argument must be a complete path name.

Declaration

Following is the declaration for java.lang.System.load() method

public static void load(String filename)
Parameters

filename − This is the file to load.

Return Value

This method does not return any value.

Exception Example: Loading Cryptography DLL

The following example shows the usage of Java System load() method. In this program, using load() method, we're passing complete path of crypt32.dll to load it and corresponding message is printed.

package com.tutorialspoint;

public class SystemDemo {

   public static void main(String[] args) {

      // print when the program starts
      System.out.println("Program starting...");

      // load a library that is Windows/System32 folder
      System.out.println("Loading Library...");
      System.load("C:/Windows/System32/crypt32.dll");
      System.out.println("Library Loaded.");
   }
}
Output

Let us compile and run the above program, this will produce the following result −

Program starting...
Loading Library...
Library Loaded.
Example: Exception while Loading a DLL

The following example shows the usage of Java System load() method. In this program, using load() method, we're passing path of a non-existing dll to load it and corresponding exception message is printed.

package com.tutorialspoint;

public class SystemDemo {

   public static void main(String[] args) {

      // print when the program starts
      System.out.println("Program starting...");

      // load a library that is Windows/System32 folder
      System.out.println("Loading Library...");
      System.load("C:/Windows/System32/crypt.dll");
      System.out.println("Library Loaded.");
   }
}
Output

Let us compile and run the above program, this will produce the following result −

Program starting...
Loading Library...
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Windows\System32\crypt.dll
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2422)
	at java.base/java.lang.Runtime.load0(Runtime.java:852)
	at java.base/java.lang.System.load(System.java:2025)
	at com.tutorialspoint.SystemDemo.main(SystemDemo.java:12)
Example: Loading File Management DLL

The following example shows the usage of Java System load() method. In this program, using load() method, we're passing complete path of filemgmt.dll to load it and corresponding message is printed.

package com.tutorialspoint;

public class SystemDemo {

   public static void main(String[] args) {

      // print when the program starts
      System.out.println("Program starting...");

      // load a library that is Windows/System32 folder
      System.out.println("Loading Library...");
      System.load("C:/Windows/System32/filemgmt.dll");
      System.out.println("Library Loaded.");
   }
}
Output

Let us compile and run the above program, this will produce the following result −

Program starting...
Loading Library...
Library Loaded.

java_lang_system.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4