*
The moose likes Ant, Maven and Other Build Tools and the fly likes Compilation error while building the project using Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Compilation error while building the project using Ant" Watch "Compilation error while building the project using Ant" New topic
Author

Compilation error while building the project using Ant

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Hi,

I am trying to build my project using ant first time.But i am getting compilation errors though if i manually do it it gets compiled.
The compiler is telling it is not able to find servlet package.


My Development directory structure is:


project1(Directory)
META-INF(Sub-Directory) jspPages(Sub-Directory) WEB-INF(Sub-Directory) index.jsp(page)


In META-INF folder one Manifest.mf file is there
In jspPages folder my jSP pages are there
In WEB-INF following directories are there:

1)lib (In this i have kept the jars which are needed for my application)

2)src (In this another folder namely 'java' is there & inside 'java' folder my src files are there.ALso my build.xml & build.properties file are there in src folder )

3)web.xml


This is my build.xml:





This is my build.properties



Also my classes & dist folders are getting created inside src folder but i want to create in WEB-INF.So how to do it??

[ May 25, 2006: Message edited by: Jignesh Gohel ]
[ May 25, 2006: Message edited by: Bear Bibeault ]

Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its possibly something to do with the long directory names you use - the spaces can cause problems. Try running Ant with the -verbose flag; this will show you what values properties have and what arguments Ant is using with the javac command. You might be able to spot the problem this way.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
I put the servlet.jar in the 'lib' directory in my current development structure as shown above instead of specifying that long path .But then also the compiler is telling that the javax.servlet.* & javax.servlet.http.* package doesn't exist so it's not able to find the classes used from that package.So how to fix this thing??

Is there any error in using that format for specifying the relative directory & context directory that is ../ & ./ Also please tell me the difference between these two signs actually i am confused between them??

Please help me!!
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Did you run your build with the -verbose flag?
[ May 25, 2006: Message edited by: Paul Sturrock ]
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Yes i did it but its not displaying the paths i have mentioned in the build.properties file.Its displaying the following:

when its coming in the compile-domain target:

[javac] DTSProductWorker.java added as DTSProductWorker.class doesn't exist. & similarly all others classes names with same message


then

[javac] Compiling 43 source files to C:\JIGNESH_GOHEL\JigneshG\project1
\WEB-INF\src\classes
[javac] Using modern compiler
dropping C:\JIGNESH_GOHEL\JigneshG\project1\WEB-INF\src\classpath.bas
e from path as it doesn't exist
[javac] Compilation arguments:
[javac] '-d'
[javac] 'C:\JIGNESH_GOHEL\JigneshG\project1\WEB-INF\src\classes'
[javac] '-classpath'
[javac] 'C:\JIGNESH_GOHEL\JigneshG\project1\WEB-INF\src\classes;C
:\ANT_HOME\apache-ant-1.6.5\lib\ant-launcher.jar;C:\ANT_HOME\apache-ant-1.6.5\li
b\ant-antlr.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-apache-bcel.jar;C:\ANT_HOME
\apache-ant-1.6.5\lib\ant-apache-bsf.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-ap
ache-log4j.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-apache-oro.jar;C:\ANT_HOME\a
pache-ant-1.6.5\lib\ant-apache-regexp.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-a
pache-resolver.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-commons-logging.jar;C:\A
NT_HOME\apache-ant-1.6.5\lib\ant-commons-net.jar;C:\ANT_HOME\apache-ant-1.6.5\li
b\ant-icontract.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-jai.jar;C:\ANT_HOME\apa
che-ant-1.6.5\lib\ant-javamail.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-jdepend.
jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-jmf.jar;C:\ANT_HOME\apache-ant-1.6.5\li
b\ant-jsch.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-junit.jar;C:\ANT_HOME\apache
-ant-1.6.5\lib\ant-netrexx.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-nodeps.jar;C
:\ANT_HOME\apache-ant-1.6.5\lib\ant-starteam.jar;C:\ANT_HOME\apache-ant-1.6.5\li
b\ant-stylebook.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-swing.jar;C:\ANT_HOME\a
pache-ant-1.6.5\lib\ant-trax.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-vaj.jar;C:
\ANT_HOME\apache-ant-1.6.5\lib\ant-weblogic.jar;C:\ANT_HOME\apache-ant-1.6.5\lib
\ant-xalan1.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\ant-xslp.jar;C:\ANT_HOME\apache
-ant-1.6.5\lib\ant.jar;C:\ANT_HOME\apache-ant-1.6.5\lib\xercesImpl.jar;C:\ANT_HO
ME\apache-ant-1.6.5\lib\xml-apis.jar;C:\TIGER_JDK1.5\lib\tools.jar'
[javac] '-sourcepath'
[javac] 'C:\JIGNESH_GOHEL\JigneshG\project1\WEB-INF\src\java'
[javac] '-g:none'
[javac]
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.



then,

the file names to be compiled


then

the errors that the servlet classes which i am using cannot be found
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You define your classpath outside your javac task so you will need to refer to it by reference rather than directly. This:

Tells Ant to tell javac to include the resource "apath" in the classpath, whereas this:

tells Ant to include whatever apath references in the classpath.
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Thanks a lot it got compiled .

One thing more please tell me when we are specifying the basedir = ../ to which ditrectory it points to??

And what is the difference between ../ & ./
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

../ and ./ behave just as they do from a command window. So ./ == the current directory and ../ == the current directory's parent directory.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compilation error while building the project using Ant
 
Similar Threads
Help with properties file
java.lang.classnotfoundexception in junit report
Struts2:NoClassDefFoundError for pdf parsing using itext
Ant building error
What's this?