使用外部库和Ant错误导出Java

时间:2015-05-01 13:59:28

标签: java eclipse ant

所以我准备好一个应用程序变成一个可运行的java jar。

我关注this example

我的build.xml看起来像这样。编辑属性行已添加

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project PaintingAPicture">
    <!--this file was created by Eclipse Runnable JAR Export Wizard-->
    <!--ANT 1.7 is required                                        -->
    <target name="jar">
    <property name="java.library.path" value="C:/opencv/build/java/x64" />

        <jar destfile="C:/Users/Robert/Desktop/Expo/Project.jar" filesetmanifest="mergewithoutmain">
            <manifest>
                <attribute name="Main-Class" value="paintPic.ThreadMaster"/>
                <attribute name="Class-Path" value="."/>
            </manifest>
            <fileset dir="C:/Users/Robert/Documents/GitHub/Project/PaintingAPicture/bin"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/opencv/build/java/opencv-2411.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/mfz-rxtx-2.2-20081207-win-x64/RXTXcomm.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/Program Files (x86)/Arduino/lib/arduino-core.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/Program Files (x86)/Arduino/lib/ecj.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/Program Files (x86)/Arduino/lib/jna.jar"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/Program Files (x86)/Arduino/lib/pde.jar"/>
        </jar>
    </target>
</project>

ant jar,工作正常,并且成功建立。

但是当我用

运行jar时
java -j Project.jar

我收到以下错误。

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java2411 in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at paintPic.ThreadMaster.main(ThreadMaster.java:24)

我的目标是将这个Jar导出到另一个设备,我只是不确定它为什么不会运行。

0 个答案:

没有答案