Failed to create Java VM

python E:\snappy_sen1GRD\insar\interferogram\
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.
Traceback (most recent call last):
File “E:\snappy_sen1GRD\insar\interferogram\”, line 17, in
RuntimeError: jpy: failed to create Java VM

Please help me on this. I can’t understand what to do. Please.

I moved your post into a separate because it doesn’t fit the topic where you have posted it originally.

For some reason, the Java VM couldn’t be started. This could be that the path to the JVM is not correct, or maybe it is already started.

The line


is your code?

Usually, you don’t need to do this, because snappy is starting the JVM already if necessary.

1 Like

Actually I used jpy.destroyJVM() to stop vm and then restart it. But somehow, it not creating new JVM. Please help me.

Can I start JVM again by importing snappy package with in a loop. like:

for i in range(0,4):
      import snappy
      from snappy import jpy # can it start the JVM again? when I am faceing problem with jpy.create_jvm(snappy.jpyutil.get_jvm_options())

      # operations

can I restart JVM using this process?

From the Current Limitations section of the JPY Documentation:

“It is currently not possible to shutdown the Java VM from Python and then restart it.”


We can’t restart jvm, problem in my code also not solved using product.dispose() also tried system.gc(). So, now what is the option now to clean java memory when using snappy. Any fixed solution ?

There have been a number of suggestions to make better use
of memory. This might allow you to get an extra iteration of the loop, but the simple workaround is to run python separately for each pair of input files. One way to do this is to convert your existing looping script to one without looping that takes the two filenames as arguments:

Similar to, add import sys to the existing list of imports, then set the file names from the command-line arguments:

if len(sys.argv) != 3:
    print("usage: %s <na> <na2>" % sys.argv[0])

na = sys.argv[1]
na2 = sys.argv[2]

In a Windows terminal:

PS> python insar_ts_one_pair_of_files D:\\radar_j_coal_f\\<name of na file>.zip D:\\radar_j_coal_f\\<name of na2 file>.zip

Now you need to run the script 36 times. Using your original loop, you would have:

import subprocess
import glob
for i in range(0,36):
    na2=list(imgs[i+1])["python", na, na2])

To test this script, replace “python” with “echo” to get a list of the arguments that will be passed the non-looping script.