How to install OpenGrok on Windows(and Linux)?

OpenGrokTo successfully setup OpenGrok, We need to perform two steps.
First, Indexing the actual source code and then setting up the opengrok web interface to navigate the indexed code. So before we jump in, first download below software

  1. Java JRE
  2. Ctags
  3. OpenGrok
  4. Tomcat (msi is preferable)

Install Java(update PATH), Extract Ctags to D:\ctags\ and extract Opengrok package to d:\opengrok\

Step 1: Indexing

java -jar d:\opengrok\lib\opengrok.jar -W D:\opengrok\configuration.xml -c D:\ctags\ctags.exe -P -S -v -s <source path> -d D:\opengrok\grokdata

  • This file/directory is created by opengrok during indexing
  • Add -i flag to exclude indexing specific file types or files -i *.zip -i *.xml
  • Add -i d:directory to exclude indexing specific directory. Example: -i d:*test* ignores indexing all test directories(-i d: is case sensitive *test* does not ignore xyzTest directory). Also to ignore a directory xyz under abc use -i d:”abc\xyz” backslash is very important!
  • Add -I flag to Include indexing only specific file types -I *.cs -I *.c

Step 2 : Web Interface

Extract D:\opengrok\lib\source.war (7zip can handle it) and modifiy source\WEB-INF\web.xml to contain below data

Now install tomcat and copy the entire above ‘source’ folder from d:\opengrok\lib to tomcat’s ‘webapps’ directory (Typically “C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\”)
NOTE: Restart tomcat if it is already started.

Open http://localhost:8080/source vola!!

NOTE: I found indexing multiple projects which are spread across different paths to be a cumbersome process. To mitigate it, I create a directory containing NTFS junctions to these project directories as shown below.
mklink /J  abc   “D:\abc\src\
mklink /J  xyz   “D:\xyz\src\
The above will create abc and xyz junctions in your current directory and I pass the current directory for indexing(-s <source path> during indexing) and in web.xml file. Problem solved.

Update(linux installation):

3 thoughts on “How to install OpenGrok on Windows(and Linux)?

  1. Very help full article, all the changes worked for me. thanks a lot.


  2. Thank you, you really made the installation process much more understandable!


Leave a Reply