How to create a bundle of SNAP jars for the usage on the classpath
This guide explains how to create a SNAP bundle from checked-out sources. The typical use-case for such a bundle is to use the SNAP-API within processing environments, such as Calvalus or CEMS.
The BundleCreator tool will collect all jar files and necessary shared in a zip file. The jar files can be added to the classpath of your application. This way you have all needed dependencies bundled and can use the SNAP API in your application.
Step-by-step guide
Check out the SNAP Engine sources, and build the project. See How to build SNAP from sources for directions.
Check out the additional toolboxes you want to bundle. Directions are also given in the link above.
On the command line, change to the directory where SNAP Engine has been checked out.
Start the BundleCreator like this:
java -cp snap-runtime/target/snap-runtime.jar org.esa.snap.runtime.BundleCreator <target-file> <snap-engine-dir> <snap-toolbox-dirs...>
The org.esa.snap.runtime.BundleCreator
is the main class which will be executed. The jar snap-runtime.jar
is the jar file where the BundleCreator class is located.
Example call:
java -cp snap-runtime/target/snap-runtime.jar org.esa.snap.runtime.BundleCreator c:\\bundle.zip "C:\\dev\\projects\\snap\\snap-engine" "C:\\dev\\projects\\snap\\s2tbx"
This call assumes that SNAP engine is checked out and built at C:\dev\projects\snap\snap-engine
and the Sentinel-2 toolbox is checked out and built at C:\dev\projects\snap\s2tbx
, and will create a SNAP-bundle at c:\bundle.zip
. Note that this example refers to Windows, but the call is exactly the same on Linux or Mac, except for the directory paths.
It is also possible to run this bundle creation also on an installed SNAP instance. Therefore the call needs to be modified a bit.
java -cp <SNAP_INSTALL_DIR>\snap\modules\ext\org.esa.snap.snap-core\org-esa-snap\snap-runtime.jar org.esa.snap.runtime.BundleCreator <targetFile> <SNAP_INSTALL_DIR>