I'm going through the lesson of creating my first program on Java and using a gradle to compile and build.
Here is the code of the program
class HelloGradle{
public static void main(String[] args) {
System.out.println("Hello, world!");
}}
I put my file into src->main->java->HelloGradle.java
Then I created build.gradle
file with such parameters inside apply plugin: 'java'
When I try to build using gradle build
it's says that BUILD success-full and create build folder
So I add such lines to build.gradle
file
apply plugin: 'application'
mainClassName = "HelloGradle"
Then I try to run it from a root folder with such command gradle run
. But build is got failed. Here is the log of an error
Task :run FAILED
Task ':run' is not up-to-date because:
Task has not declared any outputs despite executing actions.
Starting process 'command '/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/java''.
Working directory: /Users/dmytro/Desktop/java/sandbox
Command: /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/java
-Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
-cp /Users/dmytro/Desktop/java/sandbox/build/classes/java/main:/Users/dmytro/Desktop/java/sandbox/build/resources/main
HelloGradle
Successfully started process 'command '/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/java''
Error: Could not find or load main class HelloGradle
Caused by: java.lang.ClassNotFoundException: HelloGradle``
So it seems like gradle not able to find class file even though that I specified it in configuration file. What is my next step to find a solution. Thanks a lot