Using Jmeter I was able to run basic groovy scripts with JSR223 Sampler/PostProcessor but when I ran below script I get some compilation issues . I was thinking that some configuration issue is causing compilation issues .So sharing the versions here as well
Java version - java version "22.0.1" Jmeter version - 5.6.3 (latest)
Exception
JMeter 5.6.3 comes with Groovy 3.0.20 which doesn't support Java 22, you need to downgrade your JDK version.
The latest Java version you can use with Groovy 3.0.20 is Java 21
The lowest Java version you can run JMeter 5.6.3 with is Java 8
Both workarounds should resolve your issue.
If you cannot change your JDK for any reason the remaining options are in: