Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2007, 06:27 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default about the usage of ant

i used ant(vertion 1.7) and eclipse.
if i do not use the main target,the eclipse display that
BUILD FAILED
Target `main' does not exist in this project.
so every build.xml with Target `main' will be ok.
i found some book code in build.xml without Target `main' also can run. so can anybody tell me about this problem ? thankyou!!!:D

Reply With Quote
  #2 (permalink)  
Old June 8th, 2007, 01:18 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

HI,

You need to mention the default target in the project tag of your build script so that when you try to run the ant script it'll take the target mentioned in the default attribute and try to run it.
Code:
<project name="B2G" default="build" basedir=".">
If you haven't mentioned this attribute you have to use
 ant [target name]
kind of syntax to run the script.
This applies to any editor you are using or you execute from command prompt.
In eclipse you can configure which target you want to execute in the build script without specifying the default attribute using external tools option in the run menu.

Hope its helpful.

Regards,
Rakesh
Reply With Quote
  #3 (permalink)  
Old June 8th, 2007, 07:11 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi thank you for this message .
but still does work!
this is my build.xml code
<?xml version="1.0" ?>
<project default="main">
    <target name="main" depends="compile, compress" description="Main target">
        <echo>
            Building the .jar file.
        </echo>
    </target>

    <target name="compile" description="Compilation target">
        <javac srcdir="src/xptoolkit/model"/>
    </target>

  <target name="compress" description="Compression target">
        <jar jarfile="Project.jar" basedir="src/xptoolkit/model" includes="*.class" />
  </target>
</project>
the result is
compile:
    [javac] Compiling 1 source file
compress:
      [jar] Building jar: C:\Documents and Settings\Administrator.WANGPAN\workspace\antexampl e\Project.jar
main:
     [echo] Building the .jar file.
compile:
compress:
BUILD SUCCESSFUL
Total time: 1 second
that is right !!!but if i change the build.xml code which come from some book
<?xml version="1.0" ?>
<project name="hello" default="compile">

    <target name="prepare">
            <mkdir dir="/tmp/classes"/>
      </target>



    <target name="compile" depends="prepare">
        <javac srcdir="./src" destdire="/tmp/classes"/>
    </target>


</project>
the result is that
BUILD FAILED
Target `main' does not exist in this project.

Total time: 90 milliseconds




Reply With Quote
  #4 (permalink)  
Old June 8th, 2007, 07:17 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

so i find the result need the code have target "main ", "compress" or else the result failed.
and the result do not display the target "clean", "package".
i do not know why ?

Reply With Quote
  #5 (permalink)  
Old June 8th, 2007, 07:51 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
Try removing the saved configurations in eclipse and then try executing the ant script freshly.
Go to the Run->External Tools->External Tools
In this window you can see the list of saved configurations under Ant build node in the left panel. Right click on saved items and click delete.
Once you delete all the saved list then try executing the ant script freshly.

Regards,
Rakesh
Reply With Quote
  #6 (permalink)  
Old June 12th, 2007, 06:57 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you indeed Rakesh!
when i ran build.xml in the project inpackage explorer,the problem above happen.
when i ran build.xml in the ant panel, there is no problem!



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ant reload guacamole82 BOOK: Beginning JavaServer Pages 0 July 18th, 2005 07:01 PM
Building Ant jameshoty BOOK: Professional Apache Tomcat 0 January 23rd, 2005 03:54 AM
NetBeans and WebServices/ANT sakalou J2EE 0 February 3rd, 2004 02:13 PM



All times are GMT -4. The time now is 10:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.