• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

New to ant - Compilation failure

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

I have the following code in my build.xml file

<?xml version = "1.0"?>
<project name="kavitaexamples" basedir ="." default = "init">
<target name="init">
<delete dir="classes"/>
<mkdir dir="classes"/>
</target>
<target name="compile" depends="init">
<javac src="." destdir=".">
</javac>
</target>
</project>

I have my hello.java file in the current directory.

The build is successful, however the hello.class file in not created in the current directory. Only classes folder gets deleted & recreated.
Please guide me as to where I am going wrong.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to tell it which files to compile. For example
will compile all Java files in the current directory and place the result in the directory 'classes' relative to the current directory.

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

I could resolve the problem as under:



Is there a better way of copying the webapp files into tomcat? Would appreciate any pointer.

Thanks,
Kavita
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I follow the mechanism used by Maven, even when doing builds in Ant. Basically, I do this:

1) Compile the java source files
2) Copy all of the files that make up the WAR into a directory (this is an exploded WAR)
3) Convert the directory in step 2 into a WAR file
4) Copy either the exploded WAR from step 2 or the WAR file from step 4 to Tomcat

I recommend you study Maven to see how it does this, and even if you decide not to go with Maven, follow its basic build steps (and follow its directory structure).
 
Pay attention! Tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic