I have some libraries written in Groovy. I'd like to know if I can use them in python (jython). (By using I mean importing and instantiating them like normal java classes)
First I thought I could since groovy compiles down to .class
files but then I got this exception
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at org.python.core.SyspathJavaLoader.findClass(SyspathJavaLoader.java:128)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 40 more
I was getting this even after I put the groovy jars on the classpath.
This is the command I am running:
jython -Dpython.path=<absolute path to groovy compiled classfiles>:<user home>.gradle/caches:<user home>.sdkman/candidates/groovy/current/lib test.py
(where current groovy version is 2.5.7
)
test.py
from my.library.api import AGroovyClass
print("working")
In this particular case I just wanted to make sure I can at least import it. Is it possible to do this?