user4739287
user4739287

Reputation:

Unable to run the gradle run command

Here is my directory structure

Here is the directory structure

Here is my build.gradle file

enter image description here

When I try to run the Gradle command ... grade run --info I'm getting the following error

enter image description here

Please help.

Upvotes: 1

Views: 577

Answers (1)

codemonkey
codemonkey

Reputation: 3830

The location of the compiled class:

build/classes/java/main/SampleFile.class

does not match the location of the java file:

src/in/swapnilsingh/SampleFile.java

The in/swapnilsingh package directories are missing.

You are probably missing the package declaration at the top of the java file:

package in.swapnilsingh;

public class SampleFile {
    // ...
}

Without the package declaration, the compiler will output the class file to the root of the output directory, the default package.

You can either add the package to the top of the SampleFile.java file or remove the package prefix from the mainClassName in the build.gradle:

mainClassName = 'SampleFile'

Upvotes: 0

Related Questions