On 7/24/07, Kai_testing Middleton <[EMAIL PROTECTED]> wrote:
Can someone please give me some general comments about setting up the 
CLASSPATH?  I'm compiling from the command line.

Have you tried including nutch's job file only? Despite its extension,
it is actually a jar file and it should include everything necessary
to launch applications.


I found some guidance with the RunNutchInEclipse wiki where it describes this
http://wiki.apache.org/nutch-data/attachments/RunNutchInEclipse/attachments/.classpath

Is that current for nutch 0.9?

--

By the way, I discovered the SearchApp from "Introduction to Nutch, Part 2: 
Searching" is for an older version of nutch, hence the three compile errors I was 
still getting.

Here's the current version I have that will actually compile:

import org.apache.hadoop.conf.Configuration;
import java.io.IOException;
import org.apache.nutch.searcher.Hit;
import org.apache.nutch.searcher.HitDetails;
import org.apache.nutch.searcher.Hits;
import org.apache.nutch.searcher.NutchBean;
import org.apache.nutch.searcher.Query;

public class SearchApp {

  private static final int NUM_HITS = 10;

  public static void main(String[] args)
      throws IOException {

    if (args.length == 0) {
      String usage = "Usage: SearchApp query";
      System.err.println(usage);
      System.exit(-1);
    }

    Configuration conf = new Configuration();
    NutchBean bean = new NutchBean(conf);
    Query query = Query.parse(args[0], conf);
    query.addRequiredTerm(args[0]);
    Hits hits = bean.search(query, NUM_HITS);

    for (int i = 0; i < hits.getLength(); i++) {
      Hit hit = hits.getHit(i);
      HitDetails details = bean.getDetails(hit);

      String title = details.getValue("title");
      String url = details.getValue("url");
      String summary =
        bean.getSummary(details, query).toString();

      System.out.print(title);
      System.out.print(" (");
      System.out.print(url);
      System.out.println(")");
      System.out.println("\t" + summary);
    }
  }
}



----- Original Message ----
From: Kai_testing Middleton <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, July 23, 2007 6:32:22 PM
Subject: Re: SearchApp from "Introduction to Nutch, Part 2: Searching"

As a bit of a followup:  I tried compiling with every nutch jar file I could 
find (252 of them to be precise).  I still got errors.  To find all the jar 
files I did this:

$ cd $NUTCH_HOME
$ find . -name "*.jar"

Then:

$ javac -cp <all those jars> SearchApp

I still get 3 errors:

SearchApp.java:21: cannot find symbol
symbol  : constructor NutchBean()
location: class org.apache.nutch.searcher.NutchBean
    NutchBean bean = new NutchBean();
                     ^
SearchApp.java:22: cannot find symbol
symbol  : method parse(java.lang.String)
location: class org.apache.nutch.searcher.Query
    Query query = Query.parse(args[0]);
                       ^
SearchApp.java:32: incompatible types
found   : org.apache.nutch.searcher.Summary
required: java.lang.String
        bean.getSummary(details, query);
                       ^
3 errors

What's the correct approach to compile against the nutch API?

--Kai Middleton









____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222


--
Doğacan Güney

Reply via email to