Home »
Java programming language
Java System class mapLibraryName() method with example
System class mapLibraryName() method: Here, we are going to learn about the mapLibraryName() method of System class with its syntax and example.
Submitted by Preeti Jain, on September 15, 2019
System class mapLibraryName() method
- mapLibraryName() method is available in java.lang package.
- mapLibraryName() method is used to map a given library name into a platform-dependent native library name. This is a universal method for mapping a library name into the platform-specific name.
- mapLibraryName() method is static a method, it is accessible with the class name too.
- mapLibraryName() method may throw an exception at the time of library name mapping: NullPointerException: In this exception if the mapped library name is null.
Syntax:
public static String mapLibraryName(String library_name);
Parameter(s):
- String library_name – represents the name of the library.
Return value:
The return type of this method is String, it returns the mapped the given the library name.
Example:
// Java program to demonstrate the example of
// mapLibraryName() method of System Class
public class MapLibraryNameMethod {
public static void main(String[] args) {
// Display the version of operating system
System.out.println(System.getProperty("os.version"));
// Here, we are calling the mapLibraryName() method
// that will be used to map a library name (os.version)
// into a platform-specific string representing a native library
String s = System.mapLibraryName("os.version");
System.out.println(s);
}
}
Output
E:\Programs>javac MapLibraryNameMethod.java
E:\Programs>java MapLibraryNameMethod
4.8.0-41-generic
libos.version.so