Home »
Java programming language
Java System class load() method with example
System class load() method: Here, we are going to learn about the load() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 15, 2019
System class load() method
- load() method is available in java.lang package.
- load() method is used to load the java file with the given parameter named fn(filename) from a local file system.
- load() method is a static method, it is accessible with the class name too.
-
load() method may throw an exception at the time of file loading:
- SecurityException: In this exception, its checkLink() method does not allow load the specified file as passed in the method when the security manager exists.
- UnsatisfiedLinkError: In this exception, if the loaded file does not exists in the library.
- NullPointerException: In this exception, if the loaded file name is null.
Syntax:
public static void load(String fn);
Parameter(s):
- String fn – represents the name of the file with complete file path.
Return value:
The return type of this method is void, it does not return anything.
Example:
// Java program to demonstrate the example of
// load() method of System Class
public class LoadMethod {
public static void main(String[] args) {
// load a library FP30TXT.dll that is in Windows/system folder
System.out.println(" Process of Library Loading ");
Runtime.getRuntime().load("C:/Windows/system/FP30TXT.dll");
System.out.println("Process of Library Loading completion");
}
}
Output
E:\Programs>javac LoadMethod.java
E:\Programs>java LoadMethod
Process of Library Loading
Process of Library Loading completion