How to setup Opengrok ( source code search and cross reference engine ) on Ubuntu

OpenGrok is a fast and usable source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It understands various program file formats and history from many Source Code Management systems. In other words it lets you grok (profoundly understand) source code and is developed in the open, hence the name OpenGrok. It is written in Java.

Following steps helps you to setup opengrok on ubuntu machines.

Dependancies – Opengrok is dependent on JDK and universal ctags which can be installed as,

$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get remove exuberant-ctags
$ sudo snap install universal-ctags

You can refer to “How to install universal-ctags on Ubuntu” to understand more about universal ctags.

You will also needs to install Tomcat as mentioned below,

$ mkdir devlab
$ cd devlab
$ wget -c
$ tar xvf apache-tomcat-8.5.53.tar.gz
$ mv apache-tomcat-8.5.53 tomcat

You can also directly download tomcat 8 from and extract as you want.

Next, we need to create some dependent directories and copy source.war from opengrok to tomcat as,

$ mkdir -p $PWD/opengrok/{src,data,dist,etc,log}
$ tar -C $PWD/opengrok/dist --strip-components=1 -xzf opengrok-1.3.11.tar.gz
$ cp $PWD/opengrok/dist/doc/ $PWD/opengrok/etc
$ cp $PWD/opengrok/dist/lib/source.war tomcat/webapps/

Now, we will write simple script to source the environment variables as required to setup tomcat and opengrok as,

$ vim

# OpenGrok exports

export OPENGROK_INSTANCE_BASE=$PWD/opengrok/src/

Now, we can start the tomcat server as,

$ bash $PWD/tomcat/bin/

The server will be started at http://localhost:8080/

as we can see in script, we have set OPENGROK_INSTANCE_BASE as $PWD/opengrok/src/ i.e. opengrok/src directory from current “devlab” directory. This opengrok/src/ direvtory is where we have to download the source for which we want to build the cross reference / search database.

For example, we used following two git sources, you can use any git from your source code,

$ cd $PWD/opengrok/src
$ git clone
$ git clone

Now, the last step to get everything working is to run the indexer which will create the indexing of the source which can be used for searching using browser..

$ cd devlab
$ vim
#check where ctags is using "which ctags" command...
java \
    -Djava.util.logging.config.file=$PWD/opengrok/etc/ \
    -jar $PWD/opengrok/dist/lib/opengrok.jar \
    -c /snap/bin/ctags \
    -s $PWD/opengrok/src -d $PWD/opengrok/data -H -P -S -G \
    -W $PWD/opengrok/etc/configuration.xml -U http://localhost:8080/source

Time required for indexing will be depending on size of your source code from $PWD/opengrok/src , once indexing is complete you will see the opengrok up and running at http://localhost:8080/source/ as shown below,


You can download the entire source code from

References –

Registration Form Project in Javasc... x
Registration Form Project in Javascript with Source Code | Javascript Projects with Source Code

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto Embedded Linux