Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 417
ASH Avatar asked Oct 23 '18 12:10

ASH


3 Answers

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

like image 147
ASH Avatar answered Oct 19 '22 21:10

ASH


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>
like image 22
Narendra Reddy Avatar answered Oct 19 '22 20:10

Narendra Reddy


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 .

like image 1
marcor92 Avatar answered Oct 19 '22 20:10

marcor92