I following this spring guide on starting gradle. I've installed it and made a build.gradle file with only apply plugin: 'java'
in it. When I run gradle build
in bash I get the compiled .class files in build/classes/main/hello but when I try to run HelloWorld.class like so: java HelloWorld
...I get the following error... Error: Could not find or load main class HelloWorld
.
I'm not that experienced in Java but I have to learn it for school and specifically I have to learn web development but that led me to spring which in turn led me to gradle so I'm just trying to get something to work since nothing seems to be working for me.
*edit:
Here's all the code from the example...
The directory structure:
└── src
└── main
└── java
└── hello
src/main/java/hello/HelloWorld.java:
package hello;
public class HelloWorld {
public static void main(String[] args) {
Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}
src/main/java/hello/Greeter.java:
package hello;
public class Greeter {
public String sayHello() {
return "Hello world!";
}
}
The files compile in a different set of folders with the highest level one being build which is in the same directory as src.
I've tried running the command java HelloWorld
at every level of the directory structure which includes the folder that contains the .class files.
Sorry if my initial post was vague.