'Unable to find the version of JNA on macos

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.



Solution 1:[1]

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.

Solution 2:[2]

JNA must be downloaded. While the com.sun prefix of its packages may imply a connection with the JDK, is based on where it was originally developed and does not reflect any internal JDK usage.

If you are experiencing issues with a wrong-version of JNA (failure to load libraries) it is because of an application you are using which imports the wrong version. You should contact the maintainers of that library to have them update the version.

The best way to download the jar as a dependency for your code 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.

Regard the JNA/temp, part of JNA's initialization is extracting a small platform-specific native library to a temporary directory. If any project or application you have run on your machine ever used JNA, it may have written this library there. As the "temp" name implies it is safe to delete and will be rewritten (if necessary). This "temp" filename is from a much older version based on JDK 1.5; more recent versions based on JDK 1.6 have a more randomized temporary filename.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Five
Solution 2