Eclipse: Set up project and example extension from git sources
Download and install eclipse (if not already available)
- Download and unzip from
- https://www.eclipse.org/downloads/packages/
- either
- Package for Enterprise Java and Web Developers
- Package for Java Developers
- each will do fine for OJ development
All the below was tested with eclipse version 2024.06.
OpenJUMP project
Import into eclipse IDE
NOTE: The file system paths below are for windows but can analogous be some unix/linux/mac paths.
- Start the eclipse application
- Create and open a new workspace e.g. C:\workspace-OpenJUMP
- File > Import...
- Git > Projects from Git (with smart import) ; Next>
- Clone URI ; Next>
- enter URI https://github.com/openjump-gis/openjump.git ; Next>
- make sure at least branch main is selected ; Next>
- choose a location for the project folder e.g. C:\workspace-OpenJUMP\OpenJUMP ; Next>
- eclipse will now clone the git repository into the project folder
- Import Projects dialog pops up
- Folder OpenJUMP should be preselected Import as Maven
- Finish>
eclipse should now build the maven project without errors (warnings can be ignored)
Create run/debug configuration
When the project builds fine you will need to provide some information to be able to run OJ directly from the built project.
- Run > Run Configurations...
- Right click Java Application on the left side ; Select New Configuration
- change Name above tabs from
New Configuration
to
OpenJUMP - tab Main
- make sure Project is
OpenJUMP - add Main Class
com.vividsolutions.jump.workbench.JUMPWorkbench
- make sure Project is
- tab Arguments
- add Program arguments
-default-plugins scripts\default-plugins.xml -extensions-directory "lib\ext" -extensions-directory "target\lib.ext.core" -extensions-directory "target\lib.ext.plus" -I18n en_US -v info
NOTE: you can
change the language/region with the parameter -I18n or
raise the log verbosity to debug with -v or
remove -extensions-directory "target\lib.ext.plus" to simulate OJ CORE - add VM arguments
-Djava.system.class.loader=com.vividsolutions.jump.workbench.plugin.PlugInClassLoader
- add Program arguments
- save configuration with button Apply (bottom right)
- run configuration with button Run (bottom right)
eclipse should now start OJ and be able to do so in the future. you can also debug OJ by selecting the created run configuration under Run > Debug Configurations... .
there are also handy buttons on the toolbar available to do so quickly. note the small downward arrows beside them!
HelloWorld extension
OJ extension projects usually are managed/build by maven. Extensions bundle/initialize/install plugins. Here's a quick explanation.
Maven also packages them into self contained distribution jar files that can be placed under 'lib/ext/' in your OJ installation to be used. In case the extension needs additional (not-jar) files the distribution is done as zip file containing jars and files/folder to be placed under 'lib/ext/'.
Strictly speaking a checkout of the complete OJ sources is not needed to develop an extension. It is perfectly possible to do so against an OJ portable distribution. We may document that later in case somebody requests it.
Import project
generally you repeat all steps from Import OJ into eclipse above. but this time use
- URI https://github.com/openjump-gis/helloworld-extension.git
- Folder name HelloWorld-Extension
let the import finish and build.
Create run/debug configuration
same here. running OJ with the extension included utilizes the basic run/debug configuration created above. we will duplicate it and add some command line parameters for the OJ plugin loader to find and load the extension classes/files during runtime.
simply put - we will remove the folders to look for additional extensions but provide a new one where the extensions classes are compiled to. additionally we use -limit-ext-lookup false to have OJ not only to look into jar files but additionally recurse through all folders and look for extension class files as well.
- Run > Run Configurations...
- expand Java Application on the left side; Right click OpenJUMP; Select Duplicate
- a new configuration OpenJUMP (1) will be created
- edit this configuration
- change Name above tabs from
OpenJUMP (1)
to
HelloWorld - tab Arguments
- change Program arguments to
-default-plugins scripts\default-plugins.xml -extensions-directory "lib\ext" -I18n en_US -v info -limit-ext-lookup false -extensions-directory ${workspace_loc:helloworld-extension}/target/classes
NOTE: we removed target/lib.ext.core,plus as the other extensions are not strictly needed to develop an extension, they slow down startup and clutter the interface. you may add those later to test incompatibilities against them later though.
- change Program arguments to
- save configuration with button Apply (bottom right)
- run configuration with button Run (bottom right)
eclipse should now start OJ and the HelloWorld extension should show up under Plugins > Example.