The Raspberry Pi camera module can be accessed through the MMAL, V4L APIs, and some third-party libraries, including the Picamera Python library. When you need to access the camera module with Java, a well-written, feature-rich library is available, which is OpenCV.
OpenCV is currently available for Windows, Linux/Mac, Android, and iOS as pre-built libraries. However, you can build the OpenCV library for your preferred development environment using the source code. For Raspberry Pi, we will be building the OpenCV library to work with Java in a few easy steps.