Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Ant Build

 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have a simple build file as follows



I am getting this error in the Eclipse console

BUILD FAILED
Target `bin' does not exist in this project.

Whereas i am having a bin folder, and i am having the java files
under the C:\saurav\proj.

Please help.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend you don't use backslashes in filenames in Java and java-based systems such as Ant. Backslashes are not only OS-specific, they're also often interpreted as escape characters, leading to unexpected results. You can do this instead:


Or, better still:


Also, it's not a good idea to embed your output directory inside your source directory. Make a separate source directory in its own separater subtree. It makes it harder to accidentally delete all your source code and you don't run into unpleasant surprises from tools such as Eclipse that automatically clean output directories.

Also, it looks lie you're keeping the Ant build.xml separate from your actual project. It's a good idea to keep the Ant build file inside your project directory (I keep it in the project root). That way if you want to transport your project to another machine - or use a source code management system - everything's in one place.
 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim for the reply.

I have modified the build.xml like this


but still i am getting the same error.

I have kept the build.xml in the root of the eclipse project only.
Please help me to solve this problem
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got a bunch of end parens ")" where you should have curly braces "}".

Also, your classpath syntax doesn't look right. Try :

<classpath path="${build.home}/lib"/>


Originally posted by saurav sarkar:



[/QB]
 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Carol for your reply.
My build is successfull now......but the class files are
not generated under the bin folder.Please advise what to do here
 
saurav sarkar
Ranch Hand
Posts: 180
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have the build file like this



I am getting the error

BUILD FAILED
Target `bin' does not exist in this project.

Please help.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you launch ant ? "ant bin" ? You must launch it using "ant all", to execute the target called "all".
 
Karthik Rajendiran
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel the case does matter
U have given Saurav but the actual directory is saurav
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option to just to check,

  • What is the name of your build file?
  • If it is NOT the same as "build.xml", how do you invoke? Are you calling it as "ant -buildfile <Name_of_build_file.xml>" ?

  •  
    saurav sarkar
    Ranch Hand
    Posts: 180
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    <project name="myproj" default="" basedir=".">


    <property name="build.home" value="${basedir}"/>



    <target name="compile" >
    <mkdir dir="${build.home}\bin"/>

    <javac srcdir="${build.home}"
    destdir="${build.home}\bin" >

    <classpath path="${build.home}\lib"/>
    </javac>
    </target>

    </project>

    This is the latest build file ....i have removed the target='all'
    But still i am getting the same error
    I am giving the build through Eclipse by setting up the Ant build for
    my project and rt clicking on the project and say build.

    Please help
     
    Christophe Verré
    Sheriff
    Posts: 14691
    16
    Eclipse IDE Ubuntu VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you leave the default target empty, it's not going to do anything, unless you explicitly tell which target you want to execute.
    I have tried to copy/paste your build.xml, and to execute under Eclipse. Nothing happens, but the build is successful :


    Then I have tried to explicitly set the target called "compile" to be executed. It is also successful :

    The "bin" directory has been created.

    I am giving the build through Eclipse by setting up the Ant build for my project

    Do you mean : Right click on your project -> Properties -> Builder -> Ant builder ?
    If so, please tell us more about your settings in it.
    [ September 04, 2007: Message edited by: Christophe Verre ]
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3381
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes, that is correct.

    Its better NOT to leave the 'default' attribute empty. can you please recheck your configuration as christophe asked and get back?
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Christophe and Raghavan for the reply.

    here is my new build file after putting the compile
    as the default target



    the error coming is

    BUILD FAILED
    Target `bin' does not exist in this project.

    my settings in the eclipse for the Ant build

    buildfile: ${workspace_loc:/myproj/build.xml}

    Base Directory: C:\Saurav\myproj


    please help
     
    Christophe Verré
    Sheriff
    Posts: 14691
    16
    Eclipse IDE Ubuntu VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sorry, I'm puzzled. The error is "Target `bin' does not exist in this project. ", which means that you are trying to execute a target called "bin", which obviously does not exist. It might be something in your project setting. Did you check "Properties -> Builder" on your project ?
    [ September 04, 2007: Message edited by: Christophe Verre ]
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Cristophe for your reply.
    I had a target set as bin in the properties.
    But now i am getting

    Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK

    Though i have added tools.jar in the user entries of the classpath
    as well as the classpath mentioned in the build.xml

    Please help
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3381
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Can you please check your JAVA_HOME environment variable?

    It should point to the HOME direcotry where JDK is installed and not have "bin" attached with it.

    For example, if you have installed your JDK in C:\j2sdk1.4.2_12 directory, your JAVA_HOME should point to "Set JAVA_HOME=C:\j2sdk1.4.2_12" and NOT "Set JAVA_HOME=C:\j2sdk1.4.2_12\bin".
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Raghavan for the reply.
    I have had the JAVA_HOME exactly as mentioned.

    But i am giving the build in Eclispe so i dont need the
    JAVA_HOME to be set in the Environment variables.

    Is there anything i need to do in the Eclipse?
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic