Java tries to find the required DLLs in $ {java.library.path} but is not defined. Therefore, you must:
- Specify the location of opencv_java244.dll in% PATH% (for example, c: \ opencv \ build \ java \ x64 \).
- Create a dir "lib" project in your directory.
- Put there:
- javacpp.jar
- javacv.jar
- javacv-windows-x86_64.jar
- OpenCV-2.4.4-Windows-x86_64.jar
- Opencv-244.jar
If your platform bit is 32, use the * x86.jar version.
And then you can use this modified ant script from opencv / samples / java / ant / to run your application:
<project name="JavaCv" basedir="." default="rebuild-run"> <property name="src.dir" value="src"/> <property name="lib.dir" value="lib"/> <path id="classpath"> <fileset dir="${lib.dir}" includes="**/*.jar"/> </path> <property name="build.dir" value="build"/> <property name="classes.dir" value="${build.dir}/classes"/> <property name="jar.dir" value="${build.dir}/jar"/> <property name="main-class" value="${ant.project.name}"/> <target name="clean"> <delete dir="${build.dir}"/> </target> <target name="compile"> <mkdir dir="${classes.dir}"/> <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/> </target> <target name="jar" depends="compile"> <mkdir dir="${jar.dir}"/> <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> <manifest> <attribute name="Main-Class" value="${main-class}"/> </manifest> </jar> </target> <target name="run" depends="jar"> <java fork="true" classname="${main-class}"> <classpath> <path refid="classpath"/> <path location="${jar.dir}/${ant.project.name}.jar"/> </classpath> </java> </target> <target name="rebuild" depends="clean,jar"/> <target name="rebuild-run" depends="clean,run"/>
Or you can define $ {java.library.path} in ant script as follows:
<target name="run" depends="jar"> <java fork="true" classname="${main-class}"> <sysproperty key="java.library.path" path="PUT_YOUR_PATH_HERE"/> <classpath> <path refid="classpath"/> <path location="${jar.dir}/${ant.project.name}.jar"/> </classpath> </java> </target>
hypet source share