Pranav A.
Pranav A.

Reputation: 470

Gradle Jar doesn't compile the .jar correctly?

I am using Codenvy, which is an Eclipse Che IDE online, to build a Java app. I have my source code in src/main/java/App.java. App.java contains 2 classes.

When I run gradle build it compiles the classes and makes a App.jar file from them. When I run java -jar App.jar it gives me an error: no manifest attribute, in App.jar

I tried making a src/main/resources folder and putting a MANIFEST.MF file in there, but it still doensn't work. Can someone please tell me what I'm doing wrong?

Upvotes: 2

Views: 733

Answers (1)

Vikas Sachdeva
Vikas Sachdeva

Reputation: 5813

You have to specify MainClass in your build.gradle file -

jar {
    manifest {
        attributes 'Main-Class': 'com.something.MainClass'
    }
}

Upvotes: 2

Related Questions