Java - 库和本机库之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2860642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 23:11:34  来源:igfitidea点击:

Java - Difference between library and native library

javajdbcnative

提问by Alvin

Could anyone tell me the difference between library and native library in terms of java? I found the word "native library" in the following line:

谁能告诉我库和本机库在java方面的区别?我在以下行中找到了“本地库”一词:

Type 1 - drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally dependent on a native library, which limits their portability. The JDBC-ODBC Bridge driver is an example of a Type 1 driver.

类型 1 - 将 JDBC API 实现为到另一个数据访问 API(例如 ODBC)的映射的驱动程序。这种类型的驱动程序通常依赖于本地库,这限制了它们的可移植性。JDBC-ODBC 桥驱动程序是类型 1 驱动程序的一个示例。

which you can found here

你可以在这里找到

回答by Herms

"Native Library" generally means a non-Java library that's used by the system (so C/C++, etc). Think normal DLLs or libs.

“本机库”通常是指系统使用的非 Java 库(例如 C/C++ 等)。想想普通的 DLL 或库。

Java can load these native libraries through JNI.

Java 可以通过 JNI 加载这些原生库。

回答by Michael Aaron Safyan

In the context of Java, a library is one written in Java and available in the form of Java bytecode *.class files, typically compressed into a JAR archive. By contrast, a native library is one that has been compiled to machine code and is typically written in C or C++. Native libraries are *.so, *.dylib, *.dll, *.a, or *.lib files (depending on your platform) that link against the Java Native Interface (JNI) library and expose the functionality from C or C++ to Java through the Java Native Interace mechanism.

在 Java 上下文中,库是用 Java 编写的,以 Java 字节码 *.class 文件的形式提供,通常压缩为 JAR 存档。相比之下,本机库是一种已编译为机器代码的库,通常是用 C 或 C++ 编写的。本机库是 *.so、*.dylib、*.dll、*.a 或 *.lib 文件(取决于您的平台),它们链接到 Java 本机接口 (JNI) 库并将 C 或 C++ 的功能公开给Java 通过Java Native Interace 机制。

回答by aioobe

A native library is a library that contains "native" code. That is, code that has been compiled for a specific hardware architecture or operating system such as x86 or windows.

本机库是包含“本机”代码的库。也就是说,已为特定硬件架构或操作系统(例如 x86 或 Windows)编译的代码。

Including such native library in your project may break the platform-independence of you application.

在您的项目中包含此类本机库可能会破坏您的应用程序的平台独立性。

回答by Hank Gay

In this context, "library" is assumed to refer to a library written in Java (and probably distributed as a jar) whereas "native library" refers to a library written in something like C or OpenForth and compiled down to machine code.

在这种情况下,假设“库”是指用 Java 编写的库(并且可能作为 jar 分发),而“本机库”是指用 C 或 OpenForth 之类的东西编写并编译为机器代码的库。