I am trying to calibrate to beta_0 for the sample S1C data. Since SNAP 11 does not current support S1C, I am trying to build SNAP 12 SNAPSHOT from source and attempt to run the snapshot version.
Yes, I did see that. I am using SNAP in a Docker container, however, and was hoping that I can interact with it via command line (more specifically, using the gpt command) as I could do when SNAP is installed with the installer.
I am under the impression that following the tutorial you linked allows one to launch SNAP desktop with which one can interact. It would not work for my use case if that is true since I intend to run SNAP’s gpt command within a Docker container.
At the bottom of this page, how to run gpt is explained. IntelliJ IDEA
However, I admit this is not very convenient.
This last step how to build an environment comparable to an installation is missing in the documentation.
Thank you for the pointer! I think I managed to get gpt to run with VSCode. However, I will have to look into how to get everything to work within a Docker container.
In the mean time, does this
This last step how to build an environment comparable to an installation is missing in the documentation.
refer to the fact that there are no docs on how to build an installer with the snapshot version(s) of SNAP?
Can one do that, building an installer from source? If so, do you know if the subsequent installation would come with the gpt command?
Theoretically, everything needed for building an installer is in the snap-installer repository.
SNAP uses Install4J for creating the installer. It uses an open-source license.
It is possible to get a trial license. I’m not sure if the information is sufficient to build the installer. If not, one of the current developers should help. I have not created SNAP installers for years.
Dear Tim,
As Marco said, you need to install Install4J (using a trial license) and clone the snap-installer repository.
After building SNAP from sources (How to build SNAP from sources), you have to launch Install4J, load the snap.install4j file located in the snap-installer project
Thank you, @diana_harosa! I was able to build an installer and get gpt to run in my Docker container!
One follow up question. The following message pops up whenever gpt is invoked:
SEVERE: org.esa.snap.runtime.Engine: Failed to modify class loader field 'usr_paths'
java.lang.NoSuchMethodException: java.lang.ClassLoader.initializePath(java.lang.String)
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2848)
at org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:286)
at org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:265)
at org.esa.snap.runtime.Engine.<init>(Engine.java:46)
at org.esa.snap.runtime.Engine.start(Engine.java:117)
at org.esa.snap.runtime.Engine.start(Engine.java:90)
at org.esa.snap.runtime.Launcher.run(Launcher.java:51)
at org.esa.snap.runtime.Launcher.main(Launcher.java:31)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84)
at com.install4j.runtime.launcher.UnixLauncher.start(UnixLauncher.java:71)
at install4j.org.esa.snap.runtime.Launcher_gpt.main(Unknown Source)
Is this something I should worry about? Did I miss something when I built from source?
@tim, I was trying to solve exactly the same problem last week.
I just came across this post and thought I share my solution as well.
I managed to get it running only with docker, so there is not installer required.
Here is my Dockerfile:
# Start with a base image that includes Maven and Java 21
FROM maven:3.9.6-eclipse-temurin-21
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Install additional necessary packages
RUN apt-get update && apt-get install -y \
libxrender1 \
libxtst6 \
libxi6 \
libgl1-mesa-glx \
libgtk2.0-0 \
libdbus-glib-1-2 \
libhdf5-dev \
libjhdf5-java \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables for Java to find libjhdf5.so
ENV LD_LIBRARY_PATH=/usr/lib/jni:$LD_LIBRARY_PATH
ENV JAVA_LIBRARY_PATH=/usr/lib/jni
# Create directory for SNAP source code
WORKDIR /opt/snap-src
# Clone the SNAP repositories
RUN git clone https://github.com/senbox-org/snap-engine.git && \
git clone https://github.com/senbox-org/microwave-toolbox.git
# Build the SNAP Engine
WORKDIR /opt/snap-src/snap-engine
RUN mvn clean install -DskipTests
# Build the Microwave Toolbox
WORKDIR /opt/snap-src/microwave-toolbox
RUN mvn clean install -DskipTests
# Set environment variables for SNAP
ENV SNAP_HOME=/opt/snap-src/snap-engine
ENV SNAP_RUNTIME_CLASSPATH=/opt/snap-src/snap-engine/snap-runtime/target/snap-runtime.jar
# Find all JAR files and add them to the classpath
RUN find /opt/snap-src/snap-engine -name "*.jar" | grep -v "^\." | grep -v "/src/" | \
grep -v "/target/classes/" | grep -v "/target/test-classes/" > /opt/snap-src/snap-classpath.txt
# Set up environment for running GPT
RUN echo '#!/bin/bash' > /usr/local/bin/gpt && \
echo 'CLASSPATH=""' >> /usr/local/bin/gpt && \
echo 'for JAR in $(cat /opt/snap-src/snap-classpath.txt); do' >> /usr/local/bin/gpt && \
echo ' CLASSPATH="$CLASSPATH:$JAR"' >> /usr/local/bin/gpt && \
echo 'done' >> /usr/local/bin/gpt && \
echo 'for JAR in $(find /opt/snap-src/microwave-toolbox -name "*.jar" | grep -v "^\." | grep -v "/src/" | grep -v "/target/classes/" | grep -v "/target/test-classes/"); do' \
>> /usr/local/bin/gpt && \
echo ' CLASSPATH="$CLASSPATH:$JAR"' >> /usr/local/bin/gpt && \
echo 'done' >> /usr/local/bin/gpt && \
echo 'java -Xmx10G -XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=200 -cp $CLASSPATH org.esa.snap.core.gpf.main.GPT "$@"' \
>> /usr/local/bin/gpt && \
chmod +x /usr/local/bin/gpt
# Add information to the profile
RUN echo 'export SNAP_HOME=/opt/snap-src/snap-engine' >> /root/.bashrc && \
echo 'export PATH=$SNAP_HOME/bin:$PATH' >> /root/.bashrc
# Define working directory for when container is running
WORKDIR /data
CMD ["/bin/bash"]
I know its very ugly, but it seems to work well
You can simply enter the docker container and run e.g.: gpt your_graph_file.xml -P the_param_you_want_to_overwrite