I'm trying to install OpenCV on Raspbian so that I can deploy my Java code onto the RPi. However, having cmake find JNI is proving to be an irksome task. One question that was answered here noted that the administrator needed to have JAVA_HOME set as well, not just the user. So I set it in /etc/environment as well as the prior setting in .bashrc.
How to resolve "Could not find JNI", building OpenCV on Raspberry Pi?
However, cmake still cannot find JNI, even after I updated it to find the Include directories as noted in the following;
cmake find_package(JNI) not work in Ubuntu 12.04 amd64
I've tried many different combinations, including the Java installation and environment setting at, though it unzips java in /opt/java and recommends setting JAVA_HOME to there;
http://elinux.org/RPi_Java_JDK_Installation
Pertinent FindJNI.cmake lines include;
SET(JAVA_AWT_INCLUDE_DIRECTORIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
${_JAVA_HOME}/include
/usr/include
/usr/local/include
/usr/lib/java/include
/usr/local/lib/java/include
/usr/lib/jvm/jdk-7-oracle-armhf/include <-- Added by me
and
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
${_JAVA_HOME}/jre/lib/{libarch}
${_JAVA_HOME}/jre/lib
${_JAVA_HOME}/lib
${_JAVA_HOME}
/usr/lib
/usr/local/lib
/usr/lib/jvm/java/lib
/usr/lib/java/jre/lib/{libarch}
/usr/lib/jvm/jdk-7-oracle-armhf
/usr/lib/jvm/jdk-7-oracle-armhf/lib
/usr/lib/jvm/jdk-7-oracle-armhf/lib/{libarch}
/usr/lib/jvm/jdk-7-oracle-armhf/{libarch}
Pertinent OpenCV install script lines include;
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=OFF -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON WITH_QT=ON -D WITH_OPENGL=ON ..
make -j 8
sudo make install
Cmake output includes;
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY)
System is unknown to cmake, create: Platform/error pid:6186,
boost::interprocess::bad_alloc Linux to use this system, please send
your config file to cmake#www.cmake.org so
I'm at a loss for any more clues to load OpenCV on Raspbian where Java can be used - what else do I need to do?
Try this.
open Terminal < export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf
In my case I have installed java-7-openjdk-armhf and it worked for me when building opencv.
I ran into the same issue as you. The only thing that worked for me was specifying the missing paths as parameter to the cmake command.
I followed the instructions from the OpenCV website (OpenCV Java Tutorial) but modified the cmake command like this:
cmake -D BUILD_SHARED_LIBS=OFF -DJAVA_INCLUDE_PATH=/usr/lib/jvm/jdk-7-oracle-armhf/include -DJAVA_AWT_LIBRARY=/usr/lib/jvm/jdk-7-oracle-armhf/jre/lib/amd64/libawt.so -DJAVA_JVM_LIBRARY=/usr/lib/jvm/jdk-7-oracle-armhf/jre/lib/arm/server/libjvm.so ..
In your case, you're saying that you receives the message (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY), so you might only need to specify those...
Hope this helps! Good luck.
Although this is an old question I have create a fork of OpenCV 3.1.0 here which builds an OSGi-compatible JAR (bundle) for OpenCV (as well as the standard artifacts) using Maven. One of the things it does is check the build environment and native dependencies prior to build. See the README guide on the page for further information.
Related
We've been using VowPal Wabbit on Ubuntu 16. We want to move to Ubuntu 18 but there doesn't appear to be a VW build for Ubuntu 18. First - does one exists? Secondly, if not, can someone point me to the instructions to build and make a Ubuntu 18 compatible library? We use Java and JNI to talk to the library currently.
Thanks,
Ron
We haven't got proper binary releases at the moment, so you'll need to build from source. Docs are somewhat sparse on this, so I'll go over it here.
To build the Java JNI lib on Ubuntu you need the dependencies:
sudo apt install libboost-dev libboost-thread-dev libboost-program-options-dev libboost-system-dev libboost-math-dev libboost-test-dev zlib1g-dev cmake g++ default-jdk
From here: https://github.com/VowpalWabbit/vowpal_wabbit/wiki/Dependencies#ubuntu
Then you need to use CMake to generate the build files and run the build:
# The important bit here is that the submodules are downloaded.
git clone --recursive https://github.com/VowpalWabbit/vowpal_wabbit.git
cd vowpal_wabbit
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DWARNINGS=Off -DBUILD_JAVA=On -DBUILD_DOCS=Off -DBUILD_PYTHON=Off -DSTATIC_LINK_VW_JAVA=On -DBUILD_TESTS=Off
make vw_jni -j `nproc`
cd ..
mvn test -f java/pom.xml
-DBUILD_JAVA=On Java is optional so this is needed to have the target generated
-DSTATIC_LINK_VW_JAVA=On This will statically link some dependencies, optional
The vw_jni target also runs mvn check
-DBUILD_DOCS=Off -DBUILD_PYTHON=Off -DBUILD_TESTS=Off Saves time by not doing things you don't need
Java is built and tested as part of CI, an example script can be seen here.
An example of this which runs in CI is here:
https://github.com/VowpalWabbit/vowpal_wabbit/blob/master/.pipelines/build-linux-java.yml
https://github.com/VowpalWabbit/vowpal_wabbit/blob/master/.scripts/linux/build-static-java.sh
I want to ship my java application (command line tool) along with a small jre. I tried a lot using jrecreate options of ejdk but, I am unable to create jre for windows 10. Please help me in this regard. I referred the following links. It is always creating for linux. How to do it for Windows ?
I used the the following command:
jrecreate.bat --profile compact2 --dest compact2-client --vm all
https://blogs.oracle.com/jtc/introducing-the-ejdk
https://www.oracle.com/technetwork/java/embedded/embedded-se/downloads/index.html
https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/installing.htm
Assumption:
You already know what you are going to package into your JRE.
Like you have a list of dependencies or you have a jar file and you need to extract the dependencies and create a JRE with only those dependencies
If Java version is not of concern then you can stick to Java 9 and follow this post here.
https://medium.com/azulsystems/using-jlink-to-build-java-runtimes-for-non-modular-applications-9568c5e70ef4
I tried this a couple of weeks ago and it worked.
Regarding Win or Linux, it depends upon where you are running the jlink command
I used the following command to get compacted jre with profile compact1 in MAC.
jrecreate.sh -d ./compact1-jre/ -p compact1
I have a java program in which a use the GLPK Solver. The error that i receive when i run it on eclipse is the following:
The dynamic link library for GLPK for Java could not beloaded.
Consider using
java -Djava.library.path=
The current value of system property java.library.path is:
/Users/maria/Documents/solver_library/GLPK/w64
I had the same problem on my old windows computer and i solved it doing the following:
1. Adding in the Java Build Path->Libraries the glpk-java.jar file
2.Adding as the Native library location of the above jar the corresponding path (C:\ProgramFiles\solver_library\GLPK\w64
3. adding in the PATH environment variable the above path.
I am doing exactly the same things on my new MAC OS X computer but still receiving the above error. I did with exactly the same way the steps 1 and 2 above and also I modified through the terminal the PATH system variable. This now is:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/maria/Documents/solver_library/GLPK/w64
Could you please tell me if you have any idea of how to solve this? I am a new Mac user so i don't know many things.
Thanks in advance!
Here's what I did to make it work on OS X.
Install glpk.
I used for this homebrew
$ brew install glpk
$ brew install swig // this package we well need for glpk for java
Install glpk for java http://sourceforge.net/projects/glpk-java/files/glpk-java/
Unzip the archive with:
$tar -xzf glpk-java-1.0.37.tar.gz
$cd glpk-java-1.0.37
Configure with:
$./configure \
CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers \
SWIGFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
Make and install with:
$make
$make check
$make install
Now in swig dir you should have 3 jars:
glpk-java.jar, glpk-java-sources.jar, glpk-java-javadoc.jar and the .lib folder (hidden).
For compiling you need to put glpk-java.jar in your classpath and specify javac option -Djava.library.path=/YOUR_PATH/libglpk-java-1.0.37/swig/.libs
I have a Java bluetooth server running on a Windows box which I want to port to the Raspberry pi. I have lots of experience with Java but little with Bluetooth or Linux.
The pi currently has Debian Wheezy operating system and I've installed bluetooth and Java ok, and placed the bluecove-gpl and bluecove jars in the classpath.
When I try to run the server, however, Java complains
Native library bluecove_arm not available.
I've tried renaming libbluecove_arm.so from the gpl jar without success, even when setting -Dbluecove.native.path to point to it.
Does anyone know where to find the correct library, what it should be called, and where it should be placed?
[SOLVED}
Found a sh build script on the google code site which showed how to compile the java source files, generate jni headers, compile and link the c files to produce a so library file. Only hiccup was that the library file needed then to be renamed libbluecove_arm.so before it would be found. All done on the pi!
mkdir bluecovelib
cd bluecovelib
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-gpl-2.1.1-SNAPSHOT-sources.tar.gz
tar -zxvf bluecove-gpl-2.1.1-SNAPSHOT-sources.tar.gz
mkdir -p bluecove/target
cd bluecove/target
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-2.1.1-SNAPSHOT.jar
cd ../../bluecove-gpl-2.1.1-SNAPSHOT
ant all
http://privateblog.by/raspberry-pi-kak-rabotat-s-bluetooth-na-java/
First off I'm on Ubuntu linux if that matters.
I have a simple project idea based off of FreeTTS and the JSAPI (Java Speech API)
I've downloaded and unpacked FreeTTS and run their build script. Then tried compiling my code linking several jar's required in the lib directory into the class path like this:
javac -cp /home/travis/Desktop/freetts-1.2/lib/jsapi.jar:/home/travis/Desktop/freetts-1.2/lib/freetts.jar HelloUnleashedReader.java
Which then compiles to java bytecode just fine.
However when I run:
java HelloUnleashedReader
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/speech/EngineModeDesc
Any help on this issue would be greatly appreciated as there are many sites around the net discussing problems with getting it to work but not many that discuss their solution.
I see that you are using Ubuntu. You must agree to the binary license before you can use jsapi.jar. You agree to this license in the process of unpacking it. To unpack jsapi.jar in Ubuntu you would type the following:
cd ~/Desktop/freetts-1.2/lib
chmod +x ./jsapi.sh
./jsapi.sh
if you receive a message like
"./jsapi.sh: 1428: uudecode: not found"
then install uudecode with
sudo apt-get install sharutils
and try again
You need to add the jsapi.jar into your classpath. The jsapi.jar can be unpacked by running lib/jsapi.exe inside the freetts installation directory.
I got this error despite I had jsapi.jar on classpath.
java -cp `ls *.jar | awk '{ORS=":";print}'` -jar WebStartClock.jar
What helped me was specifying the main class explicitely:
java -cp `ls *.jar | awk '{ORS=":";print}'` JSAPIClock
Probably something wrong in the JAR metadata or so.