wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes help in setting classpath in ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "help in setting classpath in ant" Watch "help in setting classpath in ant" New topic
Author

help in setting classpath in ant

Thomas Greene
Ranch Hand

Joined: Aug 09, 2004
Posts: 125
i am using windows2000 and have installed ant in D Drive.
My directory structure is something like

D:\ant\source\src\com\pack1\pack2 (com\pack1\pack2 are packages)
D:\ant\source\conf.jar
D:\ant\source\datasocket.jar
D:\ant\source\thirdparty\xercesImpl.jar

and I have created the follwoing build.xml

<?xml version="1.0"?>

<project name="Proj" default="compile" basedir=".">
<property name="name" value="Proj" />
<property name="build" value="${basedir}\build" />
<property name="source" value="${basedir}\source" />
<property name="baselib" value="\source" />

<target name="compile">
<javac srcdir="${source}" destdir="${build}">
<classpath>

<pathelement location="${baselib}\mysql-connector-java-3.0.6-stable-bin.jar" />
<pathelement location="${baselib}\photos.jar" />
<pathelement location="${baselib}\conf.jar" />
<pathelement location="${baselib}\jh.jar" />
<pathelement location="${baselib}\jhall.jar" />
<pathelement location="${baselib}\jhbasic.jar" />
<pathelement location="${baselib}\jhsearch.jar" />
<pathelement location="${baselib}\datasocket.jar" />
<pathelement location="${baselib}\log4j-1.2.7.jar" />
<pathelement location="${baselib}\thirdparty\xercesImpl.jar" />
<pathelement location="${baselib}\thirdparty\xmlParserAPIs.jar" />


</classpath>
</javac>
</target>

</project>

But when i try to execute it, i get errors which indicate that java files cannot find the jar files that is some problem with the classpath.

[javac] D:\ant\source\src\com\pack1\pack2\Test.java
143: cannot resolve symbol
[javac] symbol : class Logger
[javac] location: class com\pack1\pack2\Test.java
[javac] private Logger logger = Logger.getLogger(Test.class);
...
[ August 15, 2004: Message edited by: Thomas Greene ]
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Specify your file paths using a forward slash (/).
You have used an absolute path for ${baselib}.

Execute with the -v option and you will see where you have gone wrong with the verbose output.


Tony Morris
Java Q&A (FAQ, Trivia)
Thomas Greene
Ranch Hand

Joined: Aug 09, 2004
Posts: 125
Tried changing slashes doesn't help.
With -v option I am only getting file does not exist
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: help in setting classpath in ant
 
Similar Threads
using ant for compiling java files
What is the problem with this build file?
build.xml ... what am I doing wrong?
Error while executing build.xml
how to run other's tomcat from my local system