Making a desktop app using opencv in java/kotlin on Linux (Ubuntu)

Samuel_Le
Sat, 06 Dec 2025 23:42:36 +0000
Android/Java

Hi,

I am trying to make a desktop app in kotlin to experiment with various ideas to analyze videos. However I am unable to get opencv on my app.

Things I have tried:

importing opencv as a dependency by adding it to my `build.gradle.kts` file (I tried to get it from jitpack,io or maven, and strangely adding `implementation(“org.opencv:opencv:4.10.0”)` works for including opencv to an android app)

build opencv myself and then link the jar file to my application. However, when building opecncv, java cannot be found. The command I ran was: `cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_JAVA=ON -D BUILD_opencv_java=ON -D BUILD_opencv_java_bindings_generator=ON ..`, but the output I got was:
```

– Java:
– ant: /usr/bin/ant (ver 1.10.14)
– Java: NO
– JNI: /usr/lib/jvm/java-17-openjdk-amd64/include /usr/lib/jvm/java-17-openjdk-amd64/include/linux /usr/lib/jvm/java-17-openjdk-amd64/include
– Java wrappers: YES (ANT)
– Java tests: NO
```

And then after building and obtaining the jar, the kotlin compilter would not recognize any opencv dependency.

I would really appreciate if someone could explain me either how to build opencv in a way that detects java or how to import it.

2 posts - 2 participants