How to Install the Lucene Search Engine Using Solr

I’m going to go through the steps necessary to install and start using Solr. I’ve always been interested in trying out Lucene, but I never felt like dealing with writing my own wrapper around the classes. Solr simplifies this by creating a fully working search engine as a web service.

Let’s get started. You’ll need to check to see if Java is up to date. Run the below to find out.

java -version

You need to be running at least Java 1.5. Next is to check to see if Ant is installed. Do that with.

ant -version

I’m doing this on my Mac using Leopard. Here’s some instructions on setting up Ant if you aren’t using Leopard.

Java was up to date, and ant is built in. Sweet. However, I need to install JUnit. I’ll do that first.

Download JUnit. You’ll need to put it somewhere that’s accessible by the $CLASSPATH variable. There’s more information on the JUnit FAQ.

I threw it in /usr/share and left the name as junit-4.4.jar and set my CLASSPATH to point to that file (not the directory)

export CLASSPATH=$CLASSPATH:/usr/share/junit-4.4.jar

I ran that, as well as put it in my /etc/bashrc file (which you must be root to edit) so I don’t have to deal with it again.

Compile Solr

Switch back to the directory containing the solr files, and run:

ant compile

You should see something like this:

Buildfile: build.xml



compile: [javac] Compiling 185 source files to /Users/jhaddad/src/apache-solr-1.2.0/build [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [javac] Note: Some input files use unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details.

BUILD SUCCESSFUL Total time: 3 seconds

I then ran:

ant dist

Which outputted something like this:

Buildfile: build.xml




make-manifest: [mkdir] Created dir: /Users/jhaddad/src/apache-solr-1.2.0/build/META-INF

dist-jar: [jar] Building jar: /Users/jhaddad/src/apache-solr-1.2.0/dist/apache-solr-1.2.1-dev.jar

dist-war: [war] Building war: /Users/jhaddad/src/apache-solr-1.2.0/dist/apache-solr-1.2.1-dev.war


BUILD SUCCESSFUL Total time: 0 seconds

You can run the example by going to the example directory and running

java -jar start.jar

Then go here: http://localhost:8983/solr/admin/ and check out your admin.

Load a few sample docs by going here:


and running

java -jar post.jar solr.xml monitor.xml

I will post a follow up on how to get Solr running in Tomcat, as well as examples on how to use the server.

If you found this post helpful, please consider sharing to your network. I'm also available to help you be successful with your distributed systems! Please reach out if you're interested in working with me, and I'll be happy to schedule a free one-hour consultation.