Fix the Exception “Error: Could not find or load main class cucumber.cli.Main”

Java is an amazing programming language that helps programmers to develop different applications in an efficient way. Java is so popular that all programmers prefer it to design applications, even beginners are trying to set their foot in Java programming. Java updates are still very famous and programmers go through the updates to implement java in a new way. When working on Java, you may encounter various errors, and “Error: Could not find or load main class cucumber.cli.Main” is of those errors that show up.

There is no need to get panicked when you see the error pops up. The error is about the main class.  Let’s figure out how the error warning comes up

How the error warning shows up

You may get the error in your IDE

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

The cause of the error is that the dependencies of the file ‘cucumber.rb’ doesn’t meet. When your Gemfile of the project is not upgraded to meet the ‘cucumber’ requirements as well as the framework installed, you end up with the error message.

Now that you know how and why you get the error, check out how to solve it

How to Solve “Error: Could not find or load main class cucumber.cli.Main”

We have a few short and simple solutions to fix the error. Have a look at the solutions

Solution 1 – Try deleting configurations

Sometimes, a simple solution can have a huge impact. This solution is just like that, where you just have to delete the configurations to get the error resolved. When the run configuration is not correct because of the defaulted and refactoring, the error warning pops up. Deleting all the configurations can fix the issue.

On the top right corner of the image, there is a drop-down menu to uninstall the cucumber java by clicking the option and hitting the ‘-‘. Once done, right-click on the main application that you want to launch and run. You can also do this using a keyboard shortcut; ctrl + shift + F10.

This solution resolves the issue efficiently.

Solution 2 – Add dependency to pom.xml

Another solution to remove the error “Error: Could not find or load main class cucumber.cli.Main” is to add a dependency to the pom.xml. Check out the following code

<!-- -->

And that’s how the error is resolved.


I hope you have gone through the post to fix the error “Error: Could not find or load main class cucumber.cli.Main”. Although error seems complex, its solutions are quite simple. You can try any solutions according to your project.

I wish you luck! Happy Coding! Your comments are always entertained, so feel free to drop a message below in the comment box. If you have any queries or need assistance, highlight it in the comment box.

Reference Source:

Leave a Reply

Your email address will not be published. Required fields are marked *