I am new to Java and Gradle, and have a very newbie question. I have the following Java file:
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello.....");
}
}
I am able to compile the above file using javac, and run it using command "java TestMain".
I am now trying to do the same using gradle build framework. I performed the following steps: run "gradle init --type java-library copied the above file into src/main/java/
When I run "./gradlew build", I get a TestMain.class file, and a also a "building-java-file.jar" (the whole gradle directory is in building-java-file directory).
$ ls -l build/classes/main/TestMain.class
-rw-r--r-- 1 user1 foo\eng 610 May 22 17:22 build/classes/main/TestMain.class
$ java build/classes/main/TestMain
Error: Could not find or load main class build.classes.main.TestMain
How do I run the TestMain.class? Also, what is the reason for gradle creating the jar file - building-java-file.jar?
Btw, my build.gradle file is pretty empty.
apply plugin: 'java'
repositories {
jcenter()
}
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'junit:junit:4.12'
}
Thank you, Ahmed.'