Process 'command '/path/to/jdk-11.0.6+10/bin/java'' finished with non-zero exit value 1

I am learning to understanding the project jvm-libp2p (https://github.com/libp2p/jvm-libp2p) under the hood, which makes uses of gradle 5.5.1 incorporating kotlin code. However I am not familiar with kotlin, nor gradle, so this question could be very naive.

I want to execute the example Pinger (https://github.com/libp2p/jvm-libp2p/blob/develop/examples/pinger/src/main/java/io/libp2p/example/ping/Pinger.java). But adding some additional settings to its build.gradle.kts as follow

plugins {
    ...
    application
    ...
}
application {
    mainClassName = "io.libp2p.example.Pinger"
}

The execution of gradle run throws error Process 'command '/path/to/jdk-11.0.6+10/bin/java'' finished with non-zero exit value 1 because

> Task :run FAILED
Error: Could not find or load main class io.libp2p.example.Pinger
Caused by: java.lang.ClassNotFoundException: io.libp2p.example.Pinger

However I am not sure how to add the example folder or Pinger class to classpath or path so that the gradle build can reference to Pinger class and load it when the run task gets executed. Any suggestions?

Thanks

The directory structure io/libp2p/example/ping does not match the declared package io.libp2p.example in Pinger.java. The package should be io.libp2p.example.ping (or the ping directory removed).

It’s strange. I change Pinger’s package from package io.libp2p.example to package io.libp2p.example.ping. Then recompile (gradle clean build), and rerun the command gradle run. But the result remains the same.

> Task :run FAILED
Error: Could not find or load main class io.libp2p.example.ping.Pinger
Caused by: java.lang.ClassNotFoundException: io.libp2p.example.ping.Pinger

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/newgusr/jdk-11.0.6+10/bin/java'' finished with non-zero exit value 1

Thanks for the suggestion.

Sorry, yes, the compiler will still put the compiled class file into the correct directory.

When you execute the classes task, do you not end up with a build/classes/java/main/io/libp2p/example/Pinger.class file? classes should also execute when you execute the run task.