Your build.gradle
file belongs in the root of the project, not in the src/main
directory. Your file structure for the project should be:
/build.gradle
/src/main/java/ApiExample.java
The Java plugin is going to look for the src in src/main/java
relative to the project, so your stated structure would cause the ApiExample.java
file to not be compiled or available. Therefore, ClassNotFoundException
.