You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by h2ooo x <tj...@hotmail.com> on 2004/10/12 08:25:08 UTC

Classpath when executing JAR

Hi!

I have the following Ant (1.6.2) tasks defined,

  <path id="runtime-classpath">
    <pathelement location="${dist}/myproject.jar"/>
    <pathelement location="${lib}/commons-logging-api.jar"/>
    <pathelement location="${lib}/commons-logging.jar"/>
    <pathelement location="${lib}/commons-httpclient-2.0.2.jar"/>
  </path>

  <target name="run" depends="jar">
    <java classname="MyClass" classpathref="runtime-classpath" fork="true">
    </java>
  </target>

  <target name="run2" depends="jar">
    <java jar="${dist}/myproject.jar" classpathref="runtime-classpath" 
fork="true">
    </java>
  </target>


The task "run" is executed correct but the task "run2" produced the 
following error:

  run2:
       [java] java.lang.NoClassDefFoundError: 
org/apache/commons/httpclient/HttpMethod
       [java] Exception in thread "main"
       [java] Java Result: 1


Do you have any idea what could be the problem?

_________________________________________________________________
Using a handphone prepaid card? Reload your credit online! 
http://www.msn.com.my/reloadredir/default.asp


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


Re: Classpath when executing JAR

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
It's the same at the command line.

When you run a jar with

java -jar ...

java ignores the classpath. Presumably it expects the jar to specify its 
classpath.

Conor


h2ooo x wrote:
> Hi!
> 
> I have the following Ant (1.6.2) tasks defined,
> 
>  <path id="runtime-classpath">
>    <pathelement location="${dist}/myproject.jar"/>
>    <pathelement location="${lib}/commons-logging-api.jar"/>
>    <pathelement location="${lib}/commons-logging.jar"/>
>    <pathelement location="${lib}/commons-httpclient-2.0.2.jar"/>
>  </path>
> 
>  <target name="run" depends="jar">
>    <java classname="MyClass" classpathref="runtime-classpath" fork="true">
>    </java>
>  </target>
> 
>  <target name="run2" depends="jar">
>    <java jar="${dist}/myproject.jar" classpathref="runtime-classpath" 
> fork="true">
>    </java>
>  </target>
> 
> 
> The task "run" is executed correct but the task "run2" produced the 
> following error:
> 
>  run2:
>       [java] java.lang.NoClassDefFoundError: 
> org/apache/commons/httpclient/HttpMethod
>       [java] Exception in thread "main"
>       [java] Java Result: 1
> 
> 
> Do you have any idea what could be the problem?
> 
> _________________________________________________________________

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