Wojtek
Wojtek

Reputation: 233

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)

Upvotes: 5

Views: 13290

Answers (4)

eone
eone

Reputation: 11

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

Upvotes: 1

Wojtek
Wojtek

Reputation: 233

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 :)

Upvotes: 4

Royg
Royg

Reputation: 1685

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

See image

Upvotes: 3

Uladzislau Kaminski
Uladzislau Kaminski

Reputation: 2255

Try to create you script not as Groovy class. Use this way:

Ctrl + Shift + A  -> Groovy Script  -> Set script name

Upvotes: 0

Related Questions