Installing opencv on openshift for java development - java

I am trying to install opencv on openshift. following the post mentioned here
http://codingexodus.blogspot.in/2013/04/how-to-install-opencv-on-openshift.html
I am developing in java so i have installed jdk1.8 and apache ant into the $OPENSHIFT_DATA_DIR
I had to install apache ant also so i did the same again in the $OPENSHIFT_DATA_DIR
my JAVA_HOME is set to the jdk and even ANT_HOME is also pointing to the right place
JAVA_HOME="$OPENSHIFT_DATA_DIR/jdk1.8.0_05"
I am doing a cmake in the end to generate the makefile with the command
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_SHARED_LIBS=OFF ..
going through the cmake output i do see that for java it has found the ant, jni etc. finally when i execute a
make
make install
i get the error
make: *** No targets specified and no makefile found. Stop.
there is no make file generated. what am missing.

Related

How do I use a library on a exported runnable jar?

I've got a java script that uses OpenCV 4.6.0 to modify some pics. I use Eclipse to edit the java project. I downloaded the OpenCV library (a opencv_460.jar file) which is used inside Eclipse. When I run the code, it works just fine. So I export the java project as a runnable jar.
The thing is that I want to use the jar on a different machine (ubuntu 18.04). When I run java -jar TheExportedJar.jar, I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java460 in java.library.path: /usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
I installed OpenCV 4.6.0 on the machine using CMake
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.6.0.zip
unzip opencv.zip
mkdir opencv-4.6.0/build
cd opencv-4.6.0/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PKGCONFIG=ON ..
make -j$(nproc)
sudo make install
The version is ok, everything looks fine, except it doesn't actually get installed. Things that should exist, like alternative path /usr/local/lib/pkgconfig/opencv4.pc, don't actually exist
How does java work? Why can Eclipse use a jar as a library, but I can't once the project is packed? Is there a way to skip the installation process (as every type of install I've tried was just a waste of time) and import a jar from a specified path as a library inside the java code?
What other solutions could there be?

CMake not detecting JNI properly with Temuring jdk 8 in MacOS

I am building a library on Mac Big Sur using Java 8 from Adoptium (Eclipse Temurin).
To install Java, I am using the following commands:
brew tap homebrew/cask-versions
brew install --cask temurin8
Then, I export JAVA_HOME like this:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
And it properly exports it. When I execute echo $JAVA_HOME, it returns:
/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home
However, while building the library, it tries to find JNI, and it is returning the following lines:
CMake Error at /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find JNI (missing: JAVA_INCLUDED_PATH JAVA_INCLUDED_PATH2 AWT)
Is there anything else necessary to make this work on MacOS?
Notes:
I installed cmake using brew (brew install cmake).
I have already searched in Google and StackOverflow, and none of the proposed solutions worked (I have also checked the recommended similar questions while creating this one).
I checked the variable values in the FindJNI.cmake file and everything seems correct (it should find it).
In FindJNI.cmake, the value of JAVA_AWT_INCLUDE_DIRECTORIES is correct (/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/include), and jni.h is inside that directory. However, find_path(JAVA_INCLUDE_PATH 'jni.h' $(JAVA_AWT_INCLUDE_DIRECTORIES)) is not setting JAVA_INCLUDE_PATH properly.
I created a dummy project using find_path(TEST 'jni.h' '/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/include'), looking for jni.h and it works. TEST contains the correct value.
Thank you.
Edit:
This is the call to find_package:
find_package(JNI 1.7 REQUIRED)
I was finally able to solve this by setting the requested variables as flags for cmake. I just appended the following to my cmake call:
cmake ... -DJAVA_HOME=$(/usr/libexec/java_home -v 1.8) -DJAVA_INCLUDE_PATH=$(/usr/libexec/java_home -v 1.8)/include -DJAVA_INCLUDE_PATH2=$(/usr/libexec/java_home -v 1.8)/include/darwin -DJAVA_AWT_INCLUDE_PATH=$(/usr/libexec/java_home -v 1.8)/include

Android building: JarJar can't find or load main class

I'm trying to build AOSP from source (With a few modifications) but my build stops with
[ 0% 1/35196] JarJar: out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar
FAILED: /bin/bash -c "java -jar out/host/linux-x86/framework/jarjar.jar process external/conscrypt/jarjar-rules.txt out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-full-debug.jar out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar"
Error: Could not find or load main class com.tonicsystems.jarjar.Main
ninja: build stopped: subcommand failed.
make: *** [build/core/ninja.mk:149: ninja_wrapper] Error 1
and i can't get to fix it. My source is hosted here and the path of external/jarjar is the stock one on googlesource.
Can anyone help?
I had the same problem until I realized that it's due to the wrong path where com.tonicsystems.jarjar.Main is located. At ~/android/system, JarJar's com.tonicsystems.jarjar class is located in:
external/jarjar/src/main/com/tonicsystems
When it should be
external/jarjar/src/main/java/com/tonicsystems
Like it's source (from GitHub)
src/main/java/com/tonicsystems/jarjar
P.S: I had to create the external/jarjar/src/main/java directory and then move the source.
I've run into this with an AOSP fork (I think Qualcomm's tree) before - that was caused by the Makefile fragments that generate the file lists for the jar files not dealing properly with localized versions of the "sort" utility (causing removal of important class files in addition to the duplicates that were supposed to be removed).
I don't remember all the details or the proper fix, but the workaround that got me going initially was simply disabling localization while building.
rm -rf out
export LANG=C
export LC_ALL=C
export LC_COLLATE=C
. build/envsetup.sh
lunch whatever
make droidcore -j8
What fixed this for me was something completely unrelated to jarjar itself.
I was building AOSP 7.1.1 on Ubuntu 20.04. The default python command on Ubuntu 20.04 points to python3 [1], but AOSP 7.1.1 builds using python (which is really python 2.7.5).
I updated my system with sudo apt install python which linked the python command to python2 correctly instead of python3. After this, I built successfully.
AOSP is shipped with python under the prebuilts/python directory and I'm still confused as to why the build system doesn't point to that python version.
Edit
I had more trouble with adjusting my system to use the correct version of python, ultimately I had to add python and python3 as alternatives.
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
$ sudo update-alternatives --config python
Select python2

Ant Path error when performing Apache Cordova Helloworld example for amazon-fireos

I am working through Apache Cordova Amazon-fireos guide
But I am getting an Ant path error when performing "cordova platform add amazon-fireos" command. Looking at the code it looks like it is doing a pre-req check and trying to execute ant -version but failing. I then tried skipping that pre-req only for it to then error out when it tries to execute java -version. But after the cordova command errors out I can type ant -version and java -version and both commands execute successfully, see screenshot below.
I am running Windows 7 Pro 64bit and my path variables looks like this:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_51
ANT_HOME = c:\apache-ant-1.9.3
PATH=C:\Program Files\nodejs;%ANDROID_HOME%;%ANDROID_TOOLS%;
C:\Users\Super\AppData\Roaming\npm;%JAVA_HOME%\bin;%ANT_HOME%\bin
Here is the screenshot from running the command with the -d option.
It turns out I must of accidently deleted c:\windows\system32 from the PATH variable and so it could not find the cmd command. Added the path c:\windows\system32 back in and I no longer receive the Ant error.

Not finding opencv jar after installing with homebrew

After installing opencv 2.4.8.2 with homebrew, I can't seem to find the jar file in /usr/local/Cellar/opencv/2.4.8.2/share/OpenCV
I'm using Mavericks, any ideas?
Probably you forgot to specify --with-java parameter
brew tap homebrew/science
brew install opencv --with-java
After compiling a jar file is in the path
/usr/local/Cellar/opencv/2.4.9/share/OpenCV/java/opencv-249.jar
I solved the question by installing ant (and the other dependencies of opencv) using homebrew and then using cmake to install opencv instead of homebrew. I downloaded opencv from the website then used the following commands:
cd opencv-2.4.8/
mkdir build
cd build/
cmake -DBUILD_SHARED_LIBS=OFF ..
cmake -G "Unix Makefiles" ..
make -j8
The jar will pop out in the following directory:
opencv-2.4.8/build/bin/opencv-248.jar
I had this issue and tried with the --with-java option and it didn't work.
I had to edit the formula (brew edit opencv3) and insert this options myself:
option "with-contrib", "With contrib"
option "with-java", "With java"
Just above the dependency declarations.
You will also have to ensure that -DBUILD_opencv_java=ON is in your args. Note that the value is set to ON not OFF
After you've done this. Uninstall opencv then install it again.
The error could just be because -DBUILD_opencv_java is not enabled. Enable it using brew edit opencv3

Categories

Resources