Running Groovy Script does not work with error: Could not find the main class: org.codehaus.groovy.tools.GroovyStarter
I looked into the documentation an imo set up the environment correctly but still Intellij Idea Community won't run that script. I need some help. The weird thing is, i can run groovysh and such perfectly fine from terminal.
I use Windows10 1803, groovy 2.3.7, Java 1.8.0_181 and IDEA 2018.3.6
PS: What i get from IDEA:
"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-Dtools.jar=C:\Program Files\Java\jdk1.8.0_181\lib\tools.jar" -Dgroovy.home=C:\bin\apache-groovy-2.3.7 -Dgroovy.starter.conf=C:\bin\apache-groovy-2.3.7\conf\groovy-starter.conf -javaagent:C:\bin\ideaIC\lib\idea_rt.jar=61851:C:\bin\ideaIC\bin -Dfile.encoding=UTF-8 org.codehaus.groovy.tools.GroovyStarter --conf C:\bin\apache-groovy-2.3.7\conf\groovy-starter.conf --main groovy.ui.GroovyMain --classpath . [LIST OF ALL LIBRARIES] --encoding=UTF-8 C:\bin\ideaProjects\Intrexx\src\Testscript.groovy
Please sign in to leave a comment.
Please share a sample project to reproduce: https://intellij-support.jetbrains.com/hc/articles/206869619.
I uploaded it through https://uploads.services.jetbrains.com/
Filename: Intrexx.zip
When i try to run the Testscript.groovy within i get the error.
I can't reproduce the problem, make sure Groovy library is configured correctly and includes all the jars:
https://i.imgur.com/FWJt8FY.png
https://i.imgur.com/cOLVX43.png
GroovyStarter class resides in groovy-2.3.7.jar file. Double check you see it in the classpath of the command line when the script is started: https://i.imgur.com/q71gSLP.png .
So i looked into the libraries listed in the classpath and the groovy-2.3.7.jar is listet in it.
See if reinstalling Groovy helps, this .jar may be damaged.
Solved it. Always used the wrong project type. I did use Java Project with Groovy Libs. When i use Groovy Project everything is fine. Anyway i am still wondering groovy code is not working in java projects.
Hi,
I have the same issue when trying to use Global Library. I need to Groovy script in version 2.4.13 which is not one of the default version option in IntelliJ IDEA when creating a new option.
The strange thing is that if I create a new Project:
The new project “Hello World!” sample runs perfectly.
But if I try to switch Groovy versions Add a Global library > c:\Groovy\groovy-sdk-2.4.13\groovy-2.4.13\lib and try run the sample I get the same error:
I tried to create another new Project but at point 5 above, select from Groovy SDK dropdown “Specify Groovy SDK Home” and select my c:\apache-groovy-sdk-2.4.13\groovy-2.4.13\lib folder it produces the same error. I is like IntelliJ does not like any other Groovy SDK library other than the one it will download itself when creating the project.
Please any ideas here as this is driving me mad.
Please try with JDK 11.