I am trying to install OpenCV using the Homebrew-based installation instructions from the documentation.
brew edit opencv # edit file and set -DBUILD_opencv_java=ON
brew install --build-from-source opencv
Then I try to use the resulting OpenCV jar in my Java project but it fails at runtime because the Java version used to compile does not match my runtime.
Caused by: java.lang.UnsupportedClassVersionError: org/opencv/core/Core has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I need it to be compiled with Java 8 but it is being compiled with Java 10.
How can I tell Homebrew/OpenCV which version of javac to use?
I have tried setting my JAVA_HOME to the desired location and it still does not work.