You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by chuanjiang lo <lo...@gmail.com> on 2006/07/07 07:43:33 UTC

Setting classpath when executing jar file

It seems like i'm not getting the classpath setting correctly hence there is
an error in executing my jar file..
    <!-- setting a reference -->
    <path id="libraries">
        <fileset dir="${lib.dir}">
            <include name="*.jar"/>
        </fileset>
    </path>

...
...

  <target name="run" depends="set-props">
    <java fork="true" jar="${dist.dir}/${jar.name}"
classpathref="libraries">
        <arg value="${action}"/>
    </java>
  </target>

When trying to execute the jar file, the classes in other jars is not found.
How to correctly set the classpathref?

Appreciate any help.

Re: Setting classpath when executing jar file

Posted by Dominique Devienne <dd...@gmail.com>.
>  <target name="run" depends="set-props">
>    <java fork="true" jar="${dist.dir}/${jar.name}"
> classpathref="libraries">
>        <arg value="${action}"/>
>    </java>
>  </target>

The problem is in fact that <java jar=""> always ignores any classpath
specified, because SUN's java does when using the -jar command line
switch. See the JDK Tools documentation (or my answer to the 'unusual'
post of the 4th of July...)

Use <java classname=""> to be able to specify a classpath. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org