Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Groovy Scripts in IntelliJ fails

I can't run or debug Groovy scripts in IntelliJ. I'm getting the error: Error: Could not find or load main class org.codehaus.groovy.tools.GroovyStarter. Running scripts from cmd works propertly (I'm using groovyc and groovy command).

import org.apache.pdfbox.pdmodel.PDDocument
import org.fit.pdfdom.PDFDomTree
import org.w3c.dom.Document

// load the PDF file using PDFBox
PDDocument pdf = PDDocument.load(new java.io.File("file.pdf"))
// create the DOM parser
PDFDomTree parser = new PDFDomTree()
// parse the file and get the DOM Document
Document dom = parser.createDOM(pdf)
like image 854
Wojtek Avatar asked Jun 08 '17 10:06

Wojtek


People also ask

How do I run a Groovy script in IntelliJ?

To run a Groovy script, from the context menu in the editor, select Run 'name' Ctrl+Shift+F10 .

Does IntelliJ support Groovy?

The Groovy plugin is bundled with IntelliJ IDEA and enabled by default. IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.


3 Answers

I missed https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all/2.4.12 depedency in my pom.xml file. Bug is resolved. Thanks All for your hints :)

like image 120
Wojtek Avatar answered Oct 03 '22 15:10

Wojtek


Create Run Configuration (⌘N), and set the Module to the Module that contains all of your dependencies.

See image

like image 45
Royg Avatar answered Oct 05 '22 15:10

Royg


I had had the same problem until I did the next:

  1. deleted the groovy from "Global Libraries" (Don't forget to click the 'Apply' button screenshot how to delete groovy
  2. Opened any groovy file, and click on "Configure Groovy SDK" screenshot how to select groovy
  3. Selected the folder with groovy installation (see on the screenshot above)

After all, I can run/debug my scripts from IDEA

like image 32
eone Avatar answered Oct 03 '22 15:10

eone