lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bing <nibing_...@hotmail.com>
Subject Fail to compile Java code (trying to use SolrJ with Solr)
Date Thu, 02 Feb 2012 03:57:39 GMT
Hi, all, 

I am trying to coding Java so that use SolrJ to access Solr, but failed in
the first attempt. I have some experience in Solr, but I am a newbie of
SolrJ. The following are the description of what I set, what I did, and what
I got. I will be grateful if anyone can bring out some suggestions and point
out my mistakes. 

What I have:
Following are the necessary tools installed
1. Java 1.6.0_26
2. apache-tomcat-6.0.32
3. apache-solr-3.5.0
4. apache-solr-3.5.0-src 
5. apache-maven-2.2.1
6. apache-ant-1.8.2

What I Set:
1. Classpath c:\apache-solr-3.5.0\apache-solr-3.5.0\dist 
Following are the jars might be used and also consisted in the directory
indicated in the classpath:     
    apache-solr-solrj-3.5.0.jar
    solrj-lib/commons-httpclient-3.1.jar
    solrj-lib/commons-codec-1.5.jar
2. Pom.xml in C:\apache-solr-3.5.0-src\apache-solr-3.5.0\
Adding the following dependency:
	  <dependency>
	   <groupId>org.apache.solr</groupId>
	   <artifactId>solr-solrj</artifactId>
	   <version>3.5.0</version>
  	  </dependency>


What I Did:
1. Try to compile a MySolrJTest.java. 
Following is the sc, simple enough.

import org.apache.solr.client.solrj.SolrServer;

class MySolrjTest
{
    public void query(String q)
    {
        CommonsHttpSolrServer server = null;

        try
        {
            server = new
CommonsHttpSolrServer("http://localhost:8983/solr/");
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        MySolrjTest solrj = new MySolrjTest();
        solrj.query(args[0]);
    }
}


What I Get:
After I compile the code using the following command, errors arouse:

C:\apache-solr-3.5.0-src>javac MySolrjTest.java
MySolrjTest.java:1: package org.apache.solr.client.solrj does not exist
import org.apache.solr.client.solrj.SolrServer;
                                   ^
MySolrjTest.java:7: cannot find symbol
symbol  : class CommonsHttpSolrServer
location: class MySolrjTest
        CommonsHttpSolrServer server = null;
        ^
MySolrjTest.java:11: cannot find symbol
symbol  : class CommonsHttpSolrServer
location: class MySolrjTest
            server = new
CommonsHttpSolrServer("http://localhost:8983/solr/");
                         ^
3 errors

Best 
Bing 


--
View this message in context: http://lucene.472066.n3.nabble.com/Fail-to-compile-Java-code-trying-to-use-SolrJ-with-Solr-tp3708902p3708902.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message