ASH
ASH

Reputation: 1058

Error: Could not find or load main class cucumber.cli.Main

While reworking a project in Intellij into modules, i came across this error:

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-Dorg.jetbrains.run.directory=C:\Users\Ash\Documents\1_Code Stuff\Java\Udemy course\guru-pet-clinic" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.4\lib\idea_rt.jar=55768:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.4\plugins\cucumber-java\lib\cucumber-jvmFormatter.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.4\plugins\cucumber-java\lib\cucumber-jvmFormatter3.jar" cucumber.api.cli.Main --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter "C:/Users/Ash/Documents/1_Code Stuff/Java/Udemy course/guru-pet-clinic"

Error: Could not find or load main class cucumber.cli.Main

Upvotes: 14

Views: 104386

Answers (5)

Zhivko.Kostadinov
Zhivko.Kostadinov

Reputation: 467

You can stop synchronizing/indexing each time you switch to the IDEA and it's quite useful when dealing with big projects and outside build process which triggers indexing.

Just disable checkbox System Settings -> Synchronize files on frame or editor tab activation.

Upvotes: 0

code4candy
code4candy

Reputation: 21

For me the answer of @kruemelnerd worked. Just the classname needs to be uppercase: io.cucumber.core.cli.Main

If you want to change this in general, open the link at the bottem left of the Run/Debug Configurations window: "Edit configurations template...", select Cucumber Java and set the value Main class to io.cucumber.core.cli.Main.

Upvotes: 1

marcor92
marcor92

Reputation: 537

For me, it turned out that I opened as a project the parent directory of the actual main project directory. When I opened the correct project directory in IntelliJ, that had the "src" folder as a direct subfolder, cucumber worked. For reference, see instructions here: https://www.jetbrains.com/help/idea/enabling-cucumber-support-in-project.html#folder-structure, and a similar StackOverflow thread here: Intellij IDEA Run configurations for Cucumber runner class .

Upvotes: 1

Narendra Reddy
Narendra Reddy

Reputation: 31

I think I found a solution. By adding below dependency to pom.xml will clear above exception

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>5.7.0</version>
</dependency>

Upvotes: 3

ASH
ASH

Reputation: 1058

I later found out that the Run configuration was wrong due to the refactoring and then defaulted, thus causing an error.

The way I fixed it was to delete all configurations (drop down in top right of image) and also remove cucumber java by selecting and clicking the "-"

Then I right clicked on the Main application i wanted to run and selected run, or ctrl + shift + F10 for the short cut.

enter image description here

Upvotes: 25

Related Questions