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





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.