Apache Ant java.lang.NoClassDefFoundError

0

I am new in Ant , I am doing a program client-server with Eclipse , I am using external libraries: JMapViewer-1.14.1.jar , the server works correctly the client sends me an error.

When executing from the Ubuntu terminal:

ant clean compile jar run

I receive a error in the target run :

     [java] Error: A JNI error has occurred, please check your installation and try again
     [java] Exception in thread "main" java.lang.NoClassDefFoundError: org/openstreetmap/gui/jmapviewer/JMapViewer
     [java]     at java.lang.Class.getDeclaredMethods0(Native Method)
     [java]     at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
     [java]     at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
     [java]     at java.lang.Class.getMethod0(Class.java:3018)
     [java]     at java.lang.Class.getMethod(Class.java:1784)
     [java]     at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
     [java]     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
     [java] Caused by: java.lang.ClassNotFoundException: org.openstreetmap.gui.jmapviewer.JMapViewer
     [java]     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
     [java]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
     [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
     [java]     ... 7 more
     [java] Java Result: 1

My file build.xml:

<project>

    <target name="clean">
        <delete dir="build" />
    </target>

    <target name="compile">
        <mkdir dir="build/classes" />
        <javac includeantruntime="false" srcdir="src" destdir="build/classes">
            <classpath>
                <pathelement path="/home/bryan/Scrivania/Libraries/JMapViewer-1.14.1.jar" />
                <pathelement path="/home/bryan/Scrivania/Libraries/mail.jar" />
                <pathelement path="/home/bryan/Scrivania/Libraries/postgresql-42.0.0.jre6.jar" />
            </classpath>

        </javac>
    </target>

    <target name="jar">

        <mkdir dir="build/jar" />
        <jar destfile="build/jar/UI.jar" basedir="build/classes">
            <manifest>
                <attribute name="Main-Class" value="UI" />
            </manifest>
        </jar>
    </target>

    <target name="run">
        <java jar="build/jar/UI.jar" fork="true" />
    </target>

</project>
    
asked by Bryan Romero 11.04.2017 в 16:26
source

1 answer

0

The JNI error has nothing to do with Ant. It is an execution error of your program.

It means that you are using a Java library that connects to native libraries, you can not find these native libraries (dll in Windows or so in linux).

Check the installation instructions of the libraries to know which native libraries you need to have on your machine.

    
answered by 11.04.2017 / 16:50
source