• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

CLASSPATH Help With ANT

 
Ranch Hand
Posts: 511
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using WinXP and Ant...

My project's folder consists of 3 sub-directories and my build.xml file:

<src>
<lib>
<xml>
build.xml

Everything works fine and dandy, but I want to be able to see if Ant really does append the xercesImpl.jar & xalan.jar (located in the lib directory) onto my CLASSPATH.

Before I run the build script, I did an echo %CLASSPATH% and came up with:

----------------------------------------------------------------------

F:\DevProjects\XML\JavaXML>echo %CLASSPATH%

.;F:\DevTools\Java\j2sdk1.4.2_04\lib\tools.jar;F:\DevTools\Java\j2sdk1.4.2_04\jre\lib\rt.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\servlet-api.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\jsp-api.jar;F:\DevTools\Java\j2sdkee1.3.1\lib\j2ee.jar;

----------------------------------------------------------------------

Now, when I ran the build script by doing this:



----------------------------------------------------------------------

F:\DevProjects\XML\JavaXML>ant compile
Buildfile: build.xml

init:

set.classpath:
[echo] Appending jar files to CLASSPATH.

compile:
[echo] Creating interpreted bytecode
[javac] Compiling 1 source file to F:\DevProjects\XML\JavaXML\build

BUILD SUCCESSFUL
Total time: 2 seconds
F:\DevProjects\XML\JavaXML>
---------------------------------------------------------------------------

Now, when I checked the CLASSPATH again, I didn't see the xerces.jar & xalanImpl.jar on my CLASSPATH (after the build script invocation)...
--------------------------------------------------------------------------

F:\DevProjects\XML\JavaXML>echo %CLASSPATH%

.;F:\DevTools\Java\j2sdk1.4.2_04\lib\tools.jar;F:\DevTools\Java\j2sdk1.4.2_04\jre\lib\rt.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\servlet-api.jar;F:\DevTools\Java\Tomcat\jakarta-tomcat-5.0.19\common\lib\jsp-api.jar;F:\DevTools\Java\j2sdkee1.3.1\lib\j2ee.jar;

F:\DevProjects\XML\JavaXML>

--------------------------------------------------------------------------

Everything runs fine and dandy, my question is:

Doe the appropriate jars become appended to the CLASSPATH at compile time and afterwards they don't stay on the CLASSPATH?

Am I setting it right in my build script:

--------------------------------------------------------------------------

<?xml version="1.0"?>
<project name="Build SaxTreeViewer" default="compile" basedir=".">

<property name="src" value="src"/>
<property name="build" value="build"/>
<property name="lib" value="lib"/>
<property name="xml" value="xml"/>

<target name="clean" description="Remove build directory.">
<delete dir="${build}"/>
</target>

<target name="init" description="Initializes the development environment.">
<exec executable="cmd.exe">
<arg line="cls.exe /c"/>
</exec>

<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="set.classpath" depends="init" description="Appends jar files to CLASSPATH.">
<echo>Appending jar files to CLASSPATH.</echo>
<path id="classpath">
<fileset dir="${basedir}/{lib}">
<include name="${basedir}/{lib}/*.jar"/>
</fileset>
</path>
</target>

<target name="compile" depends="set.classpath"
description="Build the entire project.">
<echo>Creating interpreted bytecode</echo>
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="run" depends="compile" description="Run the main code.">
<echo>Starting main program.</echo>
<java classname="javaxml2.SAXTreeViewer"
fork="true" dir="${basedir}">
<arg value="${xml}/contents.xml"/>
<classpath refid="classpath">
<path location="${basedir}/{lib}/*.jar"/>
<path refid="classpath"/>
</classpath>
<jvmarg value="-Xmx256m"/>
<jvmarg value="-Xms20m"/>
</java>
</target>

</project>

--------------------------------------------------------------------------

Also, how can I set the MS Dos command to use the "cls" (clear screen), whenever I run Ant?

With thanks,
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ant -v

gives detail.

Guy
 
We can walk to school together. And we can both read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic