Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Difference between library and native library

Tags:

java

jdbc

native

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:

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.

which you can found here

like image 819
Alvin Avatar asked May 18 '10 19:05

Alvin


People also ask

What is native method libraries in JVM?

Native Method Libraries are libraries that are written in other programming languages, such as C, C++, and assembly. These libraries can be loaded through JNI. So, the picture you posted is saying that JNI allows access to Native Method Libraries.

What is use of native library?

On Android, it is possible to use the Mobile SDK native API from an NDK library instead of the Java API. To use the native API, you must call TasInitialize with two extra parameters: the JNI environment and the application context. Both are passed as parameters to each JNI native method.

What are the native libraries in Android?

Android applications can contain compiled, native libraries. Native libraries are code that the developer wrote and then compiled for a specific computer architecture. Most often, this means code that is written in C or C++.

What is JNA vs JNI?

Java Native Access (JNA) is a community-developed library that provides Java programs easy access to native shared libraries without using the Java Native Interface (JNI). JNA's design aims to provide native access in a natural way with a minimum of effort. Unlike JNI, no boilerplate or generated glue code is required.


2 Answers

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

Java can load these native libraries through JNI.

like image 55
Herms Avatar answered Oct 05 '22 23:10

Herms


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.

like image 20
Michael Aaron Safyan Avatar answered Oct 06 '22 00:10

Michael Aaron Safyan