[JAVA] How to output jar with main class specified by gradle in Intellij IDEA


When you create a gradle project, output a jar and run java -jar ***. Jar ***. Jar does not have the main manifest attribute. Specify the main class to solve this.


initial state

plugins {
    id 'java'

group 'xyz.miyayu'//Depends on the environment
version '1.0-SNAPSHOT'//Depends on the environment

repositories {

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'

I'll specify the main class

//~ Abbreviation ~
version '1.0-SNAPSHOT'

//to add
        attributes 'Main-Class' : 'xyz.miyayu.hogehogeProject.MainClass'//Specify the class name
//Add up to here

repositories {
//~ Abbreviation ~

The end

Thank you for your hard work.

Recommended Posts

How to output jar with main class specified by gradle in Intellij IDEA
How to create a new Gradle + Java + Jar project in Intellij 2016.03
How to build docker environment with Gradle for intelliJ
How to select a specified date by code in FSCalendar
Set up Gradle multi-project in IntelliJ to build JAR file
Mapping to a class with a value object in How to MyBatis
How to run Ant in Gradle
How to make a jar file with no dependencies in Maven
How to filter JUnit Test in Gradle
[Rails] How to log in with a name by adding a devise name column
How to add jar file in ScalaIDE
How to create a server executable JAR and WAR with Spring gradle
[Rails] How to apply the CSS used in the main app with Administrate
[Rails] How to operate the helper method used in the main application with Administrate
How to get keycloak credentials in interceptor class
(Memo) How to solve dummy output in Ubuntu 20.04
How to color code console output in Eclipse
How to output CSV created by Rails to S3
How to get Class from Element in Java
How to separate .scss by controller in Rails
How to conditionally add html.erb class in Rails
How to build an executable jar in Maven
(Java) How to implement equals () for a class with value elements added by inheritance
How to save a file with the specified extension under the directory specified in Java to the list
JavaFX application development with IntelliJ IDEA and Gradle ~ From environment construction to sample code ~
How to embed JavaScript variables in HTML with Thymeleaf
How to implement UICollectionView in Swift with code only
How to sort in ascending / descending order with SQLite
How to call functions in bulk with Java reflection
[Ruby] How to use standard output in conditional branching
[Rails] How to search by multiple values ​​with LIKE
How to switch Tomcat context.xml with WTP in Eclipse
How to input / output IBM mainframe files in Java?
How to use java non-standard library on IntelliJ IDEA
How to use Z3 library in Scala with Eclipse
How to create a Spring Boot project in IntelliJ
Organized how to interact with the JDK in stages
How to output standard from an array with forEach
[How to insert a video in haml with Rails]
How to delete untagged images in bulk with Docker
How to make a jar with old Hadoop (hadoop-core-0.20.2-cdh3u6) in Gradle: (What to do if you get Could not expand ZIP ..)
How to use JDD library in Scala with Eclipse
How to query Array in jsonb with Rails + postgres
How to debug the generated jar file in Eclipse
How to boot by environment with Spring Boot of Maven
How to install Gradle and Kotlin with SDKMAN (Mac)
How to write in Model class when you want to save binary data in DB with PlayFramework
How to use the same Mapper class in multiple data sources with Spring Boot + MyBatis
How to read a library from a JAR file with VS Code << How to not use Maven / Gradle >>
How to use Gradle
How to get the class name / method name running in Java
Build Jar files in plugin folder with one click in IntelliJ
How to connect the strings in the List separated by commas
Failed to launch checking at Kotlin Koans in IntelliJ IDEA
How to get values in real time with TextWatcher (Android)
Uppercase only the specified range with substring. (How to use substring)
How to move another class with a button action of another class.
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
How to dynamically switch JDK when building Java in Gradle
Output relative path in .classpath file generated by gradle eclipse
How to deal with Bundler :: Dsl :: DSLError by rewriting gemfile