classpath error when executing a jar by ant

Posted by changed on Stack Overflow See other posts from Stack Overflow or by changed
Published on 2010-04-06T17:07:38Z Indexed on 2010/04/07 0:43 UTC
Read the original article Hit count: 453

Filed under:
|

Hi I am trying to execute a jar file created using ant. But i am not able to find out why libraries are not available while executing jar. I am trying to load derby embedded database driver but some how i am not getting derby.jar in classpath.

Error that i am getting is

  [java] Unable to load the JDBC driver org.apache.derby.jdbc.EmbeddedDriver
  [java] Please check your CLASSPATH.
  [java] java.lang.ClassNotFoundExcepApplication Started
  [java] tion: org.apache.derby.jdbc.EmbeddedDriver
  [java]     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

a

<path id="jar.classpath">
    <fileset dir="${lib.dir}" includes="*.jar" />
</path>

<path id="compiled-src.jar.classpath">
    <path refid="jar.classpath" />
    <pathelement location="${build.classes.dir}" />
</path>

<target name="jar" depends="compile-src" description="Create Jar">
    <mkdir dir="${dist.dir}" />
    <manifestclasspath property="lib.list" jarfile="${dist.dir}/">
        <classpath refid="jar.classpath" />
    </manifestclasspath>
    <jar destfile="${dist.dir}/${ant.project.name}.jar" basedir="${build.classes.dir}" >
        <manifest>
            <attribute name="Main-Class" value="${main-class}" />
            <attribute name="Class-Path" value="${lib.list}" />
        </manifest>
    </jar>
</target>

<target name="run" depends="jar" description="Run application from jar">
    <java jar="${dist.dir}/${ant.project.name}.jar" fork="true" />
</target>

© Stack Overflow or respective owner

Related posts about ant

Related posts about classpath