日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

Java System类loadLibrary()方法与示例

發布時間:2025/3/11 java 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java System类loadLibrary()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

系統類loadLibrary()方法 (System class loadLibrary() method)

  • loadLibrary() method is available in java.lang package.

    loadLibrary()方法在java.lang包中可用。

  • loadLibrary() method is used to load the library with the given parameter named library_name(library name) as an argument passed in the method.

    loadLibrary()方法用于使用名為library_name(library name)的給定參數作為在該方法中傳遞的參數來加載庫。

  • A java file may contain native code for that we need to load the library by using loadLibrary() method. In this method, the mapping from a library_name to a given file name is done in a system-specific manner. At the time of class loading and instantiating, the required implemented native code for the native methods will then be loaded as well.

    一個Java文件可能包含本機代碼,我們需要使用loadLibrary()方法來加載該庫。 在此方法中,以特定于系統的方式完成了從library_name到給定文件名的映射。 在類加載和實例化時,也將加載本機方法所需的已實現本機代碼。

  • loadLibrary() method is a static method, it is accessible with the class name too.

    loadLibrary()方法是靜態方法,也可以使用類名進行訪問。

  • loadLibrary() method may throw an exception at the time of library loading:

    在庫加載時, loadLibrary()方法可能會引發異常:

    • SecurityException: In this exception, its checkLink() method does not allow load the specified library as passed in the method when the security manager exists.SecurityException :在此異常中,當安全管理器存在時,其checkLink()方法不允許加載在方法中傳遞的指定庫。
    • UnsatisfiedLinkError: In this exception, if the loaded library does not exists.UnsatisfiedLinkError :在這種情況下,如果加載的庫不存在。
    • NullPointerException: In this exception, if the loaded library is null.NullPointerException :在此異常中,如果加載的庫為null。

Syntax:

句法:

public static void loadLibrary(String library_name);

Parameter(s):

參數:

  • String library_name – represents the name of the library.

    字符串library_name –代表庫的名稱。

Return value:

返回值:

The return type of this method is void, it does not return anything.

此方法的返回類型為void ,它不返回任何內容。

Example:

例:

// Java program to demonstrate the example of // loadLibrary() method of System Classpublic class LoadLibraryMethod {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().loadLibrary("C:/Windows/system/FP30TXT.dll");System.out.println("Process of Library Loading completion");} }

Output

輸出量

E:\Programs>javac LoadLibraryMethod.java E:\Programs>java LoadLibraryMethod Process of Library Loading Process of Library Loading completion

翻譯自: https://www.includehelp.com/java/system-class-loadlibrary-method-with-example.aspx

總結

以上是生活随笔為你收集整理的Java System类loadLibrary()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。