views:

88

answers:

2

I'm having some trouble figuring out how to istall Ant on cygwin. I want to use Ant to build Nutch. I've looked through a bunch of tutorials but I can't find anything that is low level enough for me to understand. I need something like...

  1. Download ant, put it here
  2. Open Cygwin
  3. type "export ANT_HOME=..."
  4. ...

Can anyone help me out here?

+1  A: 

Assuming you have a JDK already installed, you can do this:

$ export ANT_HOME=/cygdrive/c/apache-ant-1.7.1

which assumes you've unzipped Ant into C:\apache-ant-1.7.1. Then:

$ export PATH=$ANT_HOME/bin:$PATH
$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
Richard Fearn
When I do this, "Exception in thread "main" java.lang...Could not find the main class: org.apache.tools.ant.launch.Launcher. Program will exit."I assume this means Java isn't installed correctly. Is there something special I have to do other than just install netbeans somewhere?
Dan Snyder
No, Java must be installed OK or you wouldn't get that far. Although just do `java -version` to make sure it's using the version you expect. Is the Ant installation one that you've just done today? If it's old it might be worth re-installing it just to be sure. Normally, Ant should set up the classpath properly by itself.
Richard Fearn
Well, my java version is 1.6.0_21. I'm not sure that that's right but it's something, so hopefully that's all I need. I haven't installed ant at all until today. Are the 2 export lines "installing" ant? Because aside from downloading it they're all I have done.
Dan Snyder
1.6.0_21 is fine. You need to have unzipped Ant, if you haven't already done that, so the `apache-ant-1.7.1` directory contains `bin`, `lib` and so on. The `export ANT_HOME=...` sets a variable which points to the Ant installation directory. The `export PATH=...` line adds Ant's `bin` directory to your `PATH`, which then allows you to run Ant just by typing `ant` instead of specifying the full path, like `/cygdrive/c/apache-ant-1.7.1/bin/ant`.
Richard Fearn
I see, so, aside from this issue, how do I configure my environment so that the export commands have already occurred every time I open a new shell?
Dan Snyder
Put the two `export` commands into your `.bashrc` file, which is in your (Cygwin) home directory - for instance, `C:\cygwin\home\USERNAME\.bashrc`. Do you still have the `"Could not find the main class"` problem?
Richard Fearn
BTW you can just set the above environment variables the usual way in Windows: http://support.microsoft.com/kb/310519, and it will work just fine (will be recognized by both the command shell and Cygwin's bash shell), just make sure to use Windows-style paths, as in `c:\path\to\dir`
Amro
How should I set my JAVA_HOME? I went into the Windows environment variables and added "JAVA_HOME" and pointed to my jdk1.6.0_21 directory. I still get this strange issue. Do you have any idea what this issue could be? I still have the "Could not find the main class" issue.
Dan Snyder
Oh, I'm using 1.8.1 on Windows 7
Dan Snyder
"according to your error, it sounds like you need to add some Ant jar files to your CLASSPATH" How do I do this?
Dan Snyder
How do I set the classpath? and to what?
Dan Snyder
A: 

Here's a step-by-step guide:

  • simply download and unzip ANT binaries say into c:\apache-ant-1.8.1

  • download and unzip NUTCH sources say into: c:\apache-nutch-1.2

  • open the command prompt and run the following:

    cd c:\apache-nutch-1.2
    c:\apache-ant-1.8.1\bin\ant
    

    the same would work from the Bash shell, just use Cygwin-style paths:

    cd /cygdrive/c/apache-nutch-1.2
    ./cygdrive/c/apache-ant-1.8.1/bin/ant
    

That's it, you will find a new directory build containing the output.

For convenience, you might want to add the Ant bin directory to the PATH environment variable so that you don't have to give the full path each time, but that's optional.

BTW I just did those exact steps, and all went fine.

Finally, follow this tutorial to get started.

Amro
I followed your steps exactly and I got the same error I mentioned before. Is there anything else I can do?
Dan Snyder
why don't you edit your original question and post the exact error message.. Also it might help if you post the output of this command `set` (just run it in Windows command prompt)
Amro