<s>
Java	B-Language
Native	I-Language
Access	I-Language
(	O
JNA	O
)	O
is	O
a	O
community-developed	O
library	O
that	O
provides	O
Java	B-Device
programs	O
easy	O
access	O
to	O
native	O
shared	O
libraries	O
without	O
using	O
the	O
Java	B-Language
Native	I-Language
Interface	I-Language
(	O
JNI	B-Language
)	O
.	O
</s>
<s>
Unlike	O
JNI	B-Language
,	O
no	O
boilerplate	O
or	O
generated	O
glue	B-General_Concept
code	I-General_Concept
is	O
required	O
.	O
</s>
<s>
The	O
JNA	O
library	O
uses	O
a	O
small	O
native	B-Library
library	I-Library
called	O
foreign	B-Application
function	I-Application
interface	I-Application
library	O
(	O
libffi	B-Language
)	O
to	O
dynamically	O
invoke	O
native	B-Language
code	I-Language
.	O
</s>
<s>
The	O
JNA	O
library	O
uses	O
native	O
functions	O
allowing	O
code	O
to	O
load	O
a	O
library	O
by	O
name	O
and	O
retrieve	O
a	O
pointer	O
to	O
a	O
function	O
within	O
that	O
library	O
,	O
and	O
uses	O
libffi	B-Language
library	O
to	O
invoke	O
it	O
,	O
all	O
without	O
static	O
bindings	O
,	O
header	B-Language
files	I-Language
,	O
or	O
any	O
compile	O
phase	O
.	O
</s>
<s>
The	O
developer	O
uses	O
a	O
Java	B-Language
interface	I-Language
to	O
describe	O
functions	O
and	O
structures	O
in	O
the	O
target	O
native	B-Library
library	I-Library
.	O
</s>
<s>
This	O
makes	O
it	O
quite	O
easy	O
to	O
take	O
advantage	O
of	O
native	O
platform	O
features	O
without	O
incurring	O
the	O
high	O
development	O
overhead	O
of	O
configuring	O
and	O
building	O
JNI	B-Language
code	O
.	O
</s>
<s>
JNA	O
is	O
built	O
and	O
tested	O
on	O
macOS	B-Application
,	O
Microsoft	B-Application
Windows	I-Application
,	O
FreeBSD	B-Operating_System
/	O
OpenBSD	B-Operating_System
,	O
Solaris	B-Application
,	O
Linux	B-Application
,	O
AIX	B-Application
,	O
Windows	B-Operating_System
Mobile	I-Operating_System
,	O
and	O
Android	B-Application
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
tweak	O
and	O
recompile	O
the	O
native	O
build	O
configurations	O
to	O
make	O
it	O
work	O
on	O
most	O
other	O
platforms	O
that	O
run	O
Java	B-Device
.	O
</s>
<s>
The	O
following	O
table	O
shows	O
an	O
overview	O
of	O
types	O
mapping	O
between	O
Java	B-Device
and	O
native	B-Language
code	I-Language
and	O
supported	O
by	O
the	O
JNA	O
library	O
.	O
</s>
<s>
Note	O
:	O
The	O
meaning	O
of	O
TCHAR	O
changes	O
between	O
char	O
and	O
wchar_t	B-Language
according	O
to	O
some	O
preprocessor	O
definitions	O
.	O
</s>
<s>
Native	B-Library
libraries	I-Library
have	O
no	O
standardized	O
memory	O
byte	B-Application
alignment	O
flavor	O
.	O
</s>
<s>
If	O
the	O
alignment	O
details	O
are	O
not	O
given	O
in	O
the	O
documentation	O
of	O
the	O
native	B-Library
library	I-Library
,	O
the	O
correct	O
alignment	O
must	O
be	O
determined	O
by	O
trial	O
and	O
error	O
during	O
implementation	O
of	O
the	O
Java	B-Device
wrapper	O
.	O
</s>
<s>
The	O
following	O
program	O
loads	O
the	O
local	O
C	B-Language
standard	I-Language
library	I-Language
implementation	O
and	O
uses	O
it	O
to	O
call	O
the	O
printf	B-Language
function	O
.	O
</s>
<s>
Note	O
:	O
The	O
following	O
code	O
is	O
portable	O
and	O
works	O
the	O
same	O
on	O
Windows	B-Application
and	O
POSIX	O
(	O
Linux	B-Application
/	O
Unix	B-Application
/	O
macOS	B-Application
)	O
platforms	O
.	O
</s>
<s>
The	O
following	O
program	O
loads	O
the	O
C	B-Language
POSIX	I-Language
library	I-Language
and	O
uses	O
it	O
to	O
call	O
the	O
standard	O
mkdir	B-Application
function	O
.	O
</s>
<s>
The	O
program	O
below	O
loads	O
the	O
Kernel32.dll	O
and	O
uses	O
it	O
to	O
call	O
the	O
Beep	O
and	O
Sleep	B-Operating_System
functions	O
.	O
</s>
<s>
Note	O
:	O
The	O
following	O
code	O
works	O
only	O
on	O
Windows	B-Application
platforms	O
.	O
</s>
<s>
Benchmarks	O
show	O
JNA	O
averages	O
ten	O
times	O
slower	O
than	O
JNI	B-Language
.	O
</s>
