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
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.
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>
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 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With