Skip to content
Jiayi Zeng edited this page Jun 6, 2023 · 21 revisions

This page describes how to setup Protege in Eclipse for development. In this setup, Protege sources can be edited in Eclipse but the project is still compiled (outside of Eclipse) using maven. This configuration is most useful for developers who need to perform a few minor changes in the code. If you need to frequently modify the Protege sources, you can use an advanced setup, which offers a tighter integration with Eclipse. If you are interested in developing a plugin, please visit the Develop a Plugin page.

Prerequisites

Get and build the source code

This guide will assume that you will get the source code in a directory called protege.

  1. Clone Protege source code from GitHub. Type in a console:
git clone https://github.com/protegeproject/protege.git
  1. Change to the protege directory. Type in the console:
cd protege
  1. Build Protege. Type in a console:
mvn clean package

After the build completes, a Protege Desktop distribution will be available in the following directory: protege/protege-distribution/target/protege-${version}-platform-independent-bin/Protege-${version}. As an example, you may find the distribution packages are at protege-distribution/target/protege-5.1.1-SNAPSHOT-platform-independent/Protege-5.1.1-SNAPSHOT

In the end, you will get a structure for the protege folder, similar to this:

protege
   + protege-common
   + protege-desktop
   + protege-editor-core   
   + protege-editor-owl
   + protege-launcher
   license.txt
   pom.xml
   README.md

Setup the projects in Eclipse

  1. Start Eclipse, optionally create a new workspace (e.g., File menu -> Switch workspace -> select a new folder name for the new workspace)

  2. Import the pom files: File menu -> Import -> select Maven -> Existing Maven projects

In the dialog, select as root folder the protege folder that you just cloned before. Eclipse will find the master pom, as well as all the pom files from the subfolders. It will look like this:

Import the pom files into Eclipse

  1. Click on Finish, and Eclipse will create individual projects for each subfolder, it will link them to Maven and Github. After this step, the projects in Eclipse will look like this:

Imported projects in Eclipse

  1. Update Maven projects: Right-click on any project -> Maven -> Update Project ... -> select all projects, click OK. This step should fix any errors that you might have gotten after the import. Remember to update projects, each time you do a change in the pom file.

Run Protege from Eclipse

  1. Create a new launch configuration: At the menubar select "Run -> Run Configurations ...". The selection will open a dialog window called "Run Configurations".

Look at the left tree panel and select "Java Application" and continue clicking at the upper left corner, the "New launcher configuration" icon. The right panel will immediately show you a new configuration form. Put a name for this new configuration, e.g., "Launch Protege 5.0".

Screenshot:

  1. Configure the launcher by filling in each tab as showed below:

2a) Main tab.

Fill in the fields as scripted below:

  • Project: protege-launcher
  • Main class: org.protege.osgi.framework.Launcher
  • Add a check mark for the two options for including system libraries and inherited mains when searching the main class.

Screenshot:

2b) Arguments tab.

Fill in the fields as scripted below:

  • VM arguments
-Dlogback.configurationFile=${workspace_loc}/protege/protege-desktop/target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT/conf/logback.xml
-DentityExpansionLimit=100000000
-Dfile.encoding=UTF-8
  • Working directory > Other: ${workspace_loc}/protege/protege-desktop/target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT

NOTE: Make sure you replace the protege-5.1.1-SNAPSHOT label according to the version you are working on.

Screenshot:

2c) Classpath tab

Add the executable JARs for Protege to run:

  • Click on the "User Entries" label and then select "Add JARs..."
  • Pick "protege-desktop" and run down the tree following the path target/protege-5.1.1-SNAPSHOT-platform-independent/protege-5.1.1-SNAPSHOT/bin
  • Select both org.apache.felix.main.jar and protege-launcher.jar
  • Click "OK"

Screenshot:

  1. Select "Apply" at the bottom right corner and continue select "Run".

If Protege opens then congratulation you are now able to run Protege from Eclipse. If you want to run in the debug mode then use the "Debug" icon in Eclipse by applying the same configuration.

Caveats

This way of running and debugging Protege in Eclipse will likely not work with hotspot replace. If you make a change in the code, you would have to run a maven clean package, then refresh the projects in Eclipse, so that the changes take effect. The positive side of this launcher configuration is that it corresponds exactly to how Protege would run from the distribution.