small medium large xlarge

24 Aug 2016, 23:01
nadine whitfield (4 posts)

I’m getting an error when I try to run cucumber from command line without build tools. Message » Error: Could not find or load main class cucumber.api.cli.Main ===== Directory structure: features/ myNewFeature.feature

bin/ cucumber-java8-1.2.4.jar cucumber-core-1.2.4.jar cucumber-jvm-deps-1.0.5.jar gherkin-jvm-deps-1.0.3.jar gherkin-2.12.2.jar ======== using Java 8, MacOSX 10.11.16 =========== What is best way to fix this?

25 Aug 2016, 07:56
Seb Rose (21 posts)

This looks like a classpath issue.

Can you share:

1) The command you’re issuing to run Cucumber from the command line (and if that’s a command script, then the content of the script itself)

2) The value of your CLASSPATH environment variable

26 Aug 2016, 04:19
nadine whitfield (4 posts)

I’m using a command like this from Terminal » java -cp “bin/*:.” cucumber.api.cli.Main -p pretty -g demo features === Not sure what the CLASSPATH variable is set to, because I’m on a different computer tonight :( === After creating this thread, I returned to the maven repo site and downloaded cucumber-java to my bin directory.

The error went away.

I then removed cucumber-java8 jar, and it continued to work. That is where I am now. When I get back to the other machine, I’ll check the CLASSPATH and see how it is configured.

26 Aug 2016, 23:57
nadine whitfield (4 posts)

I checked $CLASSPATH on the original machine, and it is blank.

JAVA_HOME > /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home

which java > /usr/bin/java

As far as I know, Java7 is not installed. At least I did not knowingly install it.

29 Aug 2016, 09:01
Seb Rose (21 posts)

Thanks for the updates. If you are working in (any) version of Java you need the cucumber-java jar.

The cucumber-java8 jar is an optional additional jar for use if you want to write your step definitions using lamdas. At the moment there is a defect in this library and the recommendation is that you don’t use cucumber-java8 in this version of Cucumber-JVM.

29 Aug 2016, 18:28
nadine whitfield (4 posts)

OK. Thanks for the info on that. It did seem like the two cucumber-java8 jar was generating stepdefs OK, but I did not look much further into it.

For the lambdas, does the entire project have to use all the same types, or can you use annotations and lambdas in the same package?

29 Aug 2016, 20:19
Aslak Hellesøy (17 posts)

Just exclude cucumber-java8 from your project dependencies for now and write step definitions using annotated methods.

You must be logged in to comment