ClassLoader类findLibrary()方法 (ClassLoader Class findLibrary() method)

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

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

  • findLibrary() method is used to find the absolute pathname of the given native library.

    findLibrary()方法用于查找给定本机库的绝对路径名。

  • findLibrary() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    findLibrary()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • findLibrary() method does not throw an exception at the time of returning the absolute path of the given library.

    返回给定库的绝对路径时, findLibrary()方法不会引发异常。

Syntax:

句法:

    protected String findLibrary(String lib_name);

Parameter(s):

参数:

  • String lib_name – represents the name of the library.

    字符串lib_name –代表库的名称。

Return value:

返回值:

The return type of this method is String, it returns an absolute path of the given library.

该方法的返回类型为String ,它返回给定库的绝对路径。

Note: It returns null when JVM finds the library along the path given as the system property "java.library.path"

注意:当JVM沿着系统属性“ java.library.path”给出的路径找到库时,它将返回null。

Example:

例:

// Java program to demonstrate the example
// of String findLibrary(String lib_name) method of ClassLoader
class FindLibrary extends ClassLoader {// Override findLibrary() of ClassLoader
protected String findLibrary(String lib_name) {if (lib_name.equals("java.lang")) {}
return lib_name;
}
}
public class Main {public static void main(String[] args) throws Exception {// Creating an instance of FindLibrary
FindLibrary fl = new FindLibrary();
// we are finding the library java.lang and it returns
// it already exists in Java
String library = fl.findLibrary("java.lang");
System.out.println("Library Found: " + library);
}
}

Output

输出量

Library Found: java.lang

翻译自: https://www.includehelp.com/java/classloader-findlibrary-method-with-example.aspx

Java ClassLoader findLibrary()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java getresources方法_Java ClassLoader getResources()方法与示例

    ClassLoader类getResources()方法getResources()方法在java.lang包中可用. getResources()方法用于标识具有给定资源名称的所有资源. getRe ...

  3. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  4. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  5. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  6. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  7. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  8. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  9. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

最新文章

  1. 【毕业求职季】-听说你想去大厂看学妹,教你京东软件产品经理面试如何一把过
  2. 趣味图解编程算法,文科生都看懂了
  3. 照片识别出错_2.GQI2021强电专业点式专业图元识别连载
  4. windows环境下python 虚拟环境的创建和使用(virtualenvwrapper)
  5. asp.net中条件查询+分页
  6. 为啥用redis解决会话呢?
  7. 用Python爬取Bilibili视频,难吗?
  8. ftp 425 Can't open data connection. 的解决方案
  9. html网页简单代码
  10. Solidity教程:初学Solidity
  11. 西门子PLC编写抢答系统
  12. 艺不压身和艺多不养家
  13. yolov3-tiny原始weights模型转onnx模型并进行推理
  14. UE4-音效触发技巧
  15. ORACLE函数库大全
  16. CentOS搭建代理服务器
  17. 解决win10蓝牙自动断连
  18. 开源方言分词转换软件Chinese dialect convert诞生了
  19. C语言 两个整数的四则运算
  20. ChatGPT首批88个插件最全解读

热门文章

  1. html中日期格式化函数,JavaScript日期时间格式化函数分享
  2. linux命令之有关关机和查看系统信息的命令
  3. 浏览器端已支持 ES6 规范(包括 export import)
  4. tomcat7的数据库连接池tomcatjdbc的25个优势
  5. [转]使用URLConnection下载文件或图片并保存到本地
  6. 业务单号自动增长的处理办法
  7. SpringBoot自定义Starter(自动配置类)
  8. Maven高级之插件开发
  9. 工时单位天与人天的区别?
  10. 表正在被别的用户或进程使用_linux内核对进程的管理分为两个方面