How to run and debug SNAP from an IDE -IntelliJ IDEA - Error

i used the parameters specified in this link https://senbox.atlassian.net/wiki/spaces/SNAP/pages/24051775/IntelliJ+IDEA

and more specifically the ones
Main class: org.esa.snap.nbexec.Launcher
VM options: -Dsun.java2d.noddraw=true -Dsun.awt.nopixfmt=true -Dsun.java2d.dpiaware=false -Dorg.netbeans.level=INFO -Dsnap.debug=true -Xmx4G
Program arguments: --userdir “/home/ahmad/Documents/Projects/SNAP/snap-desktop/snap-application/target/snap/…/userdir” --patches “/home/ahmad/Documents/Projects/SNAP//snap-engine/$/target/classes:/home/ahmad/Documents/Projects/SNAP/s1tbx/$/target/classes” --clusters “/home/ahmad/Documents/Projects/SNAP/s1tbx/s1tbx-kit/target/netbeans_clusters/s1tbx”

I get the following error:
Exception in thread “main” java.lang.IllegalStateException: Not a valid installation directory: /home/ahmad/Documents/Projects/SNAP
at org.esa.snap.nbexec.Launcher.run(Launcher.java:101)
at org.esa.snap.nbexec.Launcher.main(Launcher.java:86)

Its looking for an directory called etc and another one called platform which are not exist, I tried to create them manually to see what they are and it seems some configurations for clusters which I don’t have its files also
How to solve that?

What have you specified as Working directory?
I guess in your case it should be
/home/ahmad/Documents/Projects/SNAP/snap-desktop/snap-application/target/snap

Also, the path to the userdir looks strange. Change it to.
/home/ahmad/Documents/Projects/SNAP/snap-desktop/snap-application/target/userdir

In the patches directory, I see a duplicated ‘/’. Don’t know if this can cause trouble

Thanks for your help
You was right about working directory.
But I figured out something not in the documentation that you need to build the snap-desktop & snap-engine before do the configuration otherwise IntelliJ IDEA will reject the paths as target not exist
Also the path to the userdir is ok no need to change it.

Thanks :slight_smile:

I’ve updated the guide to mention this. Thanks for pointing this out.

I have found another point in the documentations related to “How to create a new product reader”
manifest.mf need to update.
OpenIDE-Module-Layer: org/esa/snap/dataio/<format-name>/layer.xml
should be
OpenIDE-Module-Layer: e/g/org/esa/snap/dataio/<format-name>/layer.xml

In general in case if I found anything how should I report it?

That’s the right way to report such things.

Actually, the path is correct. In the section where the layer.xml is created the path should only be org.esa.snap.dataio.<format-name>

image
The e.g. before the path is not part of the path. This is not clear, I admit.
So I changed it to this:
image

another point in documentation I think it relate for the same name

Java code
  1. create package e.g. org.esa.snap.dataio.<format-name>

at this page
https://senbox.atlassian.net/wiki/spaces/SNAP/pages/10584125/How+to+create+a+new+product+reader
I think it need to change to the same
org.esa.snap.dataio.<format-name>

Yes, I just replaced e.g. by for example

Thank you for the Atlassian wiki link at the top of this topic. I had been attempting to build 8.0 using the README.md on github which is spare with respect to IntelliJ IDEA instruction. The Atlassian wiki pages contain more complete information which I recommend copying or linking into README.md.

FYI: SNAP/S1TBX 8.0 will not build with the latest JDK 14.0.2. This is because tools.jar has been removed since JDK 9: https://docs.oracle.com/en/java/javase/14/migrate/index.html#JSMIG-GUID-A78CC891-701D-4549-AA4E-B8DD90228B4B

I was successful building SNAP/S1TBX 8.0 using JDK 1.8 (which was still on my system), Maven 3.6.3, and IntelliJ IDEA 2020.2

1 Like

Thanks for you feedback,

The Readme.md includes a link to the Developer Guide from where you can navigate to the “Build from source” page.

Yes, JDK higher version 8 are not yet supported by SNAP.
The missing tools.jar is one of the reasons.

Marco: I do not see the developer guide link on the page I am viewing: https://github.com/senbox-org/s1tbx/blob/master/README.md
Am I looking at the wrong repository?

Oh yes, there it is missing. In the toolboxes it is not included.

@lveci @oana_hogoiu Could you add the link to the Readme files? Thanks

The link is included at the end of the readme within the snap-engine repository.

Marco and @Nicolas: I am a Java novice. And with your great developer documentation I successfully built and executed SNAP 8.0 using IntelliJ IDEA. I now would like to build a binary, or stand alone JAR, for gpt so I can execute graphs. I have not been able to figure out how to do this in IntelliJ IDEA.

That’s not easily doable. SNAP is not intended to be provided in one Jar. And creating the application is more complex and needs and installer builder like Install4J.

What you can try is to follow this guide How to create a bundle of SNAP jars for the usage on the classpath

And then write a script to invoke java with the jars on the class path. The configuration needs to be similar to the one for gpt in IDEA:
https://senbox.atlassian.net/wiki/spaces/SNAP/pages/24051775/IntelliJ+IDEA#IntelliJIDEA-Rungpt

I installed IDEA in win10.My configuration file is as follows:

Main class: org.esa.snap.nbexec.Launcher

VM options: -Dsun.java2d.noddraw=true -Dsun.awt.nopixfmt=true -Dsun.java2d.dpiaware=false -Dorg.netbeans.level=INFO -Dsnap.debug=true -Xmx4G

Program arguments: --userdir “F:\SNAP\snap-desktop\snap-application\target\snap\userdir” --patches “F:\SNAP\snap\snap-engine$\target\classes; F:SNAP\s1tbx$\target\classes; F:\SNAP\s1tbx\rstb$\target\classes; F:\SNAP\s1tbx\jlinda$\target\classes;”
–clusters "F:\SNAP\s1tbx\s1tbx-kit\target\netbeans_clusters\s1tbx;F:\SNAP\s1tbx\s1tbx-kit\target\netbeans_clusters\rstb;

Working directory: F:\SNAP\snap-desktop\snap-application\target\snap
Use classpath of module: snap-main

I run the “Application” configuration file, and also get the following information:
Exception in thread “main” java.lang.IllegalStateException: Not a valid installation directory: F:\SNAP\snap-desktop\snap-application\target\snap

How to solve this problem?

Hello,
First, did you build the projects using maven?
From your error message, the target folder is not created…

My project is shown in the following figure:

But have you run the maven command mvn clean install on the projects?
It is described here How to build SNAP from sources - SNAP Wiki

Hello Marpet, I followed the steps in the link to establish SNAP, but the code below shows an error after execution.

cd …
git clone https://github.com/senbox-org/snap-desktop.git
cd snap-desktop
mvn clean install

The error message is as follows:
Failed to execute goal on project snap-product-library-ui-v2: Could not resolve dependencies for project org.esa.snap:snap-product-library-ui-v2:nbm:8.0.0-SNAPSHOT: Could not transfer artifact gov.nasa:worldwind:jar:2.1.0 from/to snap-repo-public (https://snap-build-server.tilaa.cloud/nexus/repository/snap-maven-public/): GET request of: gov/nasa/worldwind/2.1.0/worldwind-2.1.0.jar from snap-repo-public failed

Have you tried it again. Maybe the server has some temporary issue. Actually the file is available. You can see it when you follow this link:
Browse - Nexus Repository Manager

Sometimes you need to run the command multiple times because maven doesn’t manage to download all the dependencies when executing it the first time.