- Java Native Access
Infobox Software
name = Java Native Access
caption =
developer =
latest release version = 3.0.5
latest release date = release date|2008|08|14
latest preview version =
latest preview date =
operating system =Cross-platform
size = 606.9 KB (archived)
programming language = C and Java
genre = Software Library
license =LGPL version 2.1 or later.
website = https://jna.dev.java.netJava Native Access provides Java programs easy access to native shared libraries (DLLs on Windows) without using
Java Native Interface . JNA's design aims to provide native access in a natural way with a minimum of effort. No boilerplate or generated glue code is required. While some attention is paid to performance, correctness and ease of use take priority. The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code.Adoption
Java Native Access is known to be used in:
*JRuby use JNA for POSIX functionality [ [http://headius.blogspot.com/2007/09/java-native-access-jruby-true-posix.html Java Native Access + JRuby = True POSIX] ]
*Freedom for Media in Java (FMJ) [ [http://fmj-sf.net/ Freedom for Media in Java] ]
*IntelliJ IDEA IDE by the companyJetBrains
*SVNKit pure Java Subversion client library.
*Videolan JVLC Java Multimedia Library.Mapping types
The following table shows the mapping of types between Java and native code and supported by the JNA library.
Example
The following program loads the the stdio.h "standard input/output header" from C standard library and uses it to call the "
printf " function. Note that the code is portable and works the same on Windows andLinux /Unix /Mac OS X platforms.The following program loads the the
C POSIX library and uses it to call the standard "mkdir " function. Note that the code is portable and works the same onPOSIX standards platforms.The program below loads the
Kernel32.dll and uses it to call the "Beep" and "Sleep" functions.
Note: The following code works only onWindows platforms.References
ee also
*
Java Native Interface
*P/InvokeExternal links
* [https://jna.dev.java.net Java Native Access Web Page]
* [http://www.javaworld.com/javaworld/jw-02-2008/jw-02-opensourcejava-jna.html Java Native Access:An easier way to access native code] By Jeff Friesen, JavaWorld.com, 02/05/08
Wikimedia Foundation. 2010.