You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Maria Ivanova <m_...@prosyst.bg> on 2003/04/02 18:50:30 UTC

java task classpath is not added to java.class.path?

Hello,

How to add classpath to java.class.path when running a java task (is it possible without using <jvmarg value="-classpath" /> <jvmarg value="${some.classpath}" />")?  I could not make it using the <classpath> element.

Here is a test project: 

<?xml version="1.0"?>
<project name="framework" default="test" basedir=".">
 <target name="test">
  <java classname="demo.jsp.DeviceBean">
   <classpath>
    <pathelement path=".;D:/develop/embeddedsoft/frameworktools/bin/tools/framework/jsp/jsptool.jar;../../../lib/frameworklib.jar"/>
    <pathelement path="${java.class.path}" />
   </classpath>
  </java>
 </target>
</project>


The DeviceBean class prints the java.class.path property, here is the output of the test target: 

test:
     [java] >>>>>>>java.class.path is:c:\jdk1.2.2\lib\tools.jar;D:\develop\embed
dedsoft\embsoft-general\tools\ant\lib\xml-apis.jar;D:\develop\embeddedsoft\embso
ft-general\tools\ant\lib\xercesImpl.jar;D:\develop\embeddedsoft\embsoft-general\
tools\ant\lib\optional.jar;D:\develop\embeddedsoft\embsoft-general\tools\ant\lib
\ant.jar;

The custom classpath (.;D:/develop/embeddedsoft/frameworktools/bin/tools/framework/jsp/jsptool.jar;../../../lib/frameworklib.jar) is not added to java.class.path. The jar files from the classpath exist.

Any idea? 


Best regards,
 
--------------------------------------------------------
Maria Ivanova, Developer
Dept: mBedded Server/Core    
ProSyst Bulgaria, Inc.       
48 Vladaiska Str, Sofia 1606, Bulgaria         
Tel.  (+359 2) 952 35 81 (108)
http://www.prosyst.com/
--------------------------------------------------------
Leading Software Technology for Open Service Gateways
--------------------------------------------------------

Re: java task classpath is not added to java.class.path?

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Thu, 3 Apr 2003 02:50 am, Maria Ivanova wrote:
> Hello,
>
> How to add classpath to java.class.path when running a java task (is it
> possible without using <jvmarg value="-classpath" /> <jvmarg
> value="${some.classpath}" />")?  I could not make it using the <classpath>
> element.
>

In general you should not rely on the contents of the java.class.path 
property. It provides the classpath that was in effect when the Virtual 
Machine was started. If your class is loaded through a classloader, the 
property will not reflect the path being used by this classloader.

So, in your case, you see the Ant classpath since you are running in Ant's VM. 
If you want to see the path in java.class.path, you will need your own VM. 
You achieve that by using the fork attribute on the <java> task. 

-- 
Conor MacNeill
Blog: http://codefeed.com/blog/