The Java System mapLibraryName() method maps a library name into a platform-specific string representing a native library.
DeclarationFollowing is the declaration for java.lang.System.mapLibraryName() method
public static String mapLibraryName(String libname)Parameters
libname − This is the name of the library.
Return ValueThis method returns a platform-dependent native library name.
ExceptionNullPointerException − if libname is null
Example: Mapping a Library name for Operating System NameThe following example shows the usage of Java System mapLibraryName() method. In this program, we've retrieved Operating System name using "os.name" key and then using mapLibraryName(), corresponding mapped library is printed.
package com.tutorialspoint; public class SystemDemo { public static void main(String[] args) { // prints the name of the Operating System System.out.println(System.getProperty("os.name")); /* maps a library name into a platform-specific string representing a native library */ String str = System.mapLibraryName("os.name"); System.out.println(str); } }Output
Let us compile and run the above program, this will produce the following result −
Windows 11 os.name.dllExample: Mapping a Library name for User Directory
The following example shows the usage of Java System mapLibraryName() method. In this program, we've retrieved user directory name using "user.dir" key and then using mapLibraryName(), corresponding mapped library is printed.
package com.tutorialspoint; public class SystemDemo { public static void main(String[] args) { // prints the name of the User Directory System.out.println(System.getProperty("user.dir")); /* maps a library name into a platform-specific string representing a native library */ String str = System.mapLibraryName("user.dir"); System.out.println(str); } }Output
Let us compile and run the above program, this will produce the following result −
C:\Users\Tutorialspoint\eclipse-workspace\Tutorialspoint user.dir.dllExample: Mapping a Library name for Java Version
The following example shows the usage of Java System mapLibraryName() method. In this program, we've retrieved user directory name using "java.runtime.version" key and then using mapLibraryName(), corresponding mapped library is printed.
package com.tutorialspoint; public class SystemDemo { public static void main(String[] args) { // prints the name of the User Directory System.out.println(System.getProperty("java.runtime.version")); /* maps a library name into a platform-specific string representing a native library */ String str = System.mapLibraryName("java.runtime.version"); System.out.println(str); } }Output
Let us compile and run the above program, this will produce the following result −
21.0.2+13-LTS-58 java.runtime.version.dll
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