Is JNA installed with Java? I have open JDK 11. Does JNA come packaged in the JDK or is it a library that I have to install separately? If it has to be installed separately, how can I know the version?
I want to make sure that I am at least on JNA 5.6. I can see a JNA/temp
in Library/Cache
, but I am not sure where this is coming from.
CodePudding user response:
JNA is a community-developed library. I think that JNA is not included in JDK.
You can find the required dependencies at mvnrepository.com under their namespace or you can check out the project on GitHub
I don't know where that JNA/temp comes from but I know they used a hardcoded temp/JNA back in my time so maybe it is some transitive dependency.
CodePudding user response:
JNA must be downloaded. The best way to do that is to use a project dependency manager such as Maven or Gradle. The syntax to include JNA in your project can be found by searching Maven Central.
Here's a link to search where you can see that the current version (as of this post) is 5.10.0. Clicking on that number will bring you to a page showing you the syntax to include it:
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.10.0</version>
</dependency>
Note there are two artifacts: jna
which provides the core functionality, and jna-platform
which contains many user-contributed mappings and utility methods that will prevent you from having to re-invent solutions.
Regaring JNA/temp
, part of JNA's execution is extracting a small native library to a temporary directory. If any project or application you have run on your machine used JNA, it may have written its library there. The temp
filename is from a much older versions; more recent versions have a more randomized temporary filename.