Setup Apache Solr on Windows with Jetty Running as a Service via NSSM
*This works on my machine. In no way do I know what I am doing. Please post questions to http://stackoverflow.com.
Initial Solr Setup
Install the latest Java JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html. Make sure to select 64bit version if you need it.

Download Solr 1.4.1 from one of the mirrors at http://www.apache.org/dyn/closer.cgi/lucene/solr/ (at the time of writing, not all mirrors seem to be hosting 1.4.1, but most seem to have at least 1.4.0)

Unzip the Solr download. You should have the files listed in the image below. Open the example folder.

Copy the etc, lib, logs, solr, webapps, and start.jar folders to C:\solr (you will need to create the folder at C:\solr)

Now open the C:\solr\solr folder and copy the contents back to the root C:\solr folder. When you are done you can delete the C:\solr\solr folder.

At this point your C:\solr directory should look like the image below.

Solr can now be run at this point if you start it from the command line. Change your directory to c:\solr and then run: java -Dsolr.solr.home=c:/solr/ -jar start.jar <= slash direction seems to matter

If you go to http://localhost:8983/solr/ you should be greeted with the Welcome to Solr message.

Setup Jetty to Run as a Windows Service using NSSM
Now that Solr is up and running, we can work on getting Jetty to run as a Windows service. Since Jetty comes bundled with Solr, all we need is a way to run it as a service. There are several options to do this, but the one that I have found works the best and is the most compatible across windows environments is NSSM – the Non Sucking Service.
Once you download NSSM, open the win32 or win64 folder as appropriate and copy nssm.exe to your c:\solr folder.
=> 
Open an elevated command prompt and change the directory to C:\solr. and then run: nssm install Solr

A dialog will open. Select java.exe as the Application located at C:\Windows\System32\
In the options input box enter: -Dsolr.solr.home=C:/solr/ -Djetty.home=C:/solr/ -Djetty.logs=C:/solr/logs/ -cp C:/solr/lib/*.jar;C:/solr/start.jar -jar C:/solr/start.jar

Important! If you copy and paste the line above make sure to take out the line break.
Click Install service. You should get a Service successfully installed message.

Finally run: net start Solr

Jetty should now be running as a service. Check by going to http://localhost:/8983/solr
Not working? The best way to see what is going on is to stop the service and then run java.exe -Dsolr.solr.home=C:/solr/ -Djetty.home=C:/solr/ -Djetty.logs=C:/solr/logs/ -cp C:/solr/lib/*.jar;C:/solr/start.jar -jar C:/solr/start.jar from the C:\Windows\System32\ folder and review all the log information in the output.
Something not working? Please post your questions on StackOverflow.









