
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java System mapLibraryName() Method
Description
The Java System mapLibraryName() method maps a library name into a platform-specific string representing a native library.
Declaration
Following 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 Value
This method returns a platform-dependent native library name.
Exception
NullPointerException − if libname is null
Example: Mapping a Library name for Operating System Name
The 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.dll
Example: 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.dll
Example: 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