Installation
Using Maven is recommended, but manual installation is also possible.
Maven Project
The picam
library is available from the Maven Central repository, you can add
it to your Maven project by adding a new dependency:
Version 2.x of picam does not require any further library dependencies.
Companion Native Library
Version 2.x of picam uses a pure JNI implementation rather than the JNA implementation used with version 1.x. This new JNI implementation comes with a native library file that must be installed somewhere on your Pi so your Java application may use it.
The native library project is at GitHub, and you can compile and install that library manually if you so wish.
However, it is much easier to have the picam library automatically install the pre-built native library that is bundled with the picam jar file. For example:
The static installTempLibrary
statically imported function takes care of
extracting the native library from the picam jar file, copying that library
file to a temporary directory, and loading the native library into your Java
application.
The native library file will be automatically deleted from the temporary directory when your Java application terminates.
An alternate installLibrary(String)
method is also provided if you want to
specify the directory that the native library should be installed into rather
than using the temporary directory.
This alternate method can also take an overwrite
parameter that you can use
to control whether or not any pre-existing native library (of the same version
number) will be overwritten.
If you use this alternate method, the native library will not be automatically deleted when your Java application terminates.
Manual Installation
If you are not using Maven for your project, you can install the required jar file manually.
You will need the following jar:
picam-{picamVersion}.jar
If you want to manually build and install the companion native library, then you must explicitly load the native library when your Java application starts: