title: Spring Boot + Kotlin + Gradle - Error: Main method not found in class
body: <p>I'm learning spring boot with Kotlin (since I come from Android with Kotlin). I set it up with gradle. In my local machine everything works just fine. But I'm having a few issues while trying to deploy it to Heroku.</p>
  <p>This is the error I'm getting:</p>
  <pre><code>Error: Main method not found in class com.markoid.packit.PackitApplication, please define the main method as:
  2021-07-01T20:58:51.075484+00:00 app[web.1]:    public static void main(String[] args)
  2021-07-01T20:58:51.075581+00:00 app[web.1]: or a JavaFX application class must extend javafx.application.Application
  </code></pre>
  <p>I read on other posts that I need to add system.properties file in the root, so I did, but nothing changes.</p>
  <p><em>system.properties</em></p>
  <pre><code>java.runtime.version=11
  </code></pre>
  <p>And this is my <em>build.gradle.kts</em></p>
  <pre><code>import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  
  plugins {
      id(&quot;org.springframework.boot&quot;) version &quot;2.5.1&quot;
      id(&quot;io.spring.dependency-management&quot;) version &quot;1.0.11.RELEASE&quot;
      kotlin(&quot;jvm&quot;) version &quot;1.5.10&quot;
      kotlin(&quot;plugin.spring&quot;) version &quot;1.5.10&quot;
  }
  
  group = &quot;com.markoid&quot;
  version = &quot;1.0.0-SNAPSHOT&quot;
  java.sourceCompatibility = JavaVersion.VERSION_11
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      // Spring Boot Core
      implementation(&quot;org.springframework.boot:spring-boot-starter-web&quot;)
      implementation(&quot;org.springframework.boot:spring-boot-starter-validation&quot;)
      implementation(&quot;org.springframework.boot:spring-boot-starter-security&quot;)
      implementation(&quot;org.springframework.boot:spring-boot-starter-mail&quot;)
      implementation(&quot;org.springframework.boot:spring-boot-starter-data-mongodb&quot;)
  
      // Joda Time library
      implementation(&quot;joda-time:joda-time:2.10&quot;)
  
      // Json Web Token
      implementation(&quot;io.jsonwebtoken:jjwt-impl:0.11.1&quot;)
      implementation(&quot;io.jsonwebtoken:jjwt-api:0.11.1&quot;)
      implementation(&quot;io.jsonwebtoken:jjwt-jackson:0.11.1&quot;)
  
      // Serializers
      implementation(&quot;com.fasterxml.jackson.module:jackson-module-kotlin&quot;)
  
      // Documentation
      implementation(&quot;io.springfox:springfox-swagger2:2.6.1&quot;)
  
      // Kotlin related
      implementation(&quot;org.jetbrains.kotlin:kotlin-reflect&quot;)
      implementation(&quot;org.jetbrains.kotlin:kotlin-stdlib-jdk8&quot;)
  
      // Testing Frameworks
      testImplementation(&quot;org.springframework.boot:spring-boot-starter-test&quot;)
  }
  
  tasks.withType&lt;KotlinCompile&gt; {
      kotlinOptions {
          freeCompilerArgs = listOf(&quot;-Xjsr305=strict&quot;)
          jvmTarget = &quot;11&quot;
      }
  }
  
  tasks.withType&lt;Test&gt; {
      useJUnitPlatform()
  }
  
  tasks.withType&lt;Jar&gt; {
      manifest {
          attributes[&quot;Main-Class&quot;] = &quot;com.markoid.packit.PackitApplication&quot;
      }
  }
  </code></pre>
  <p>My app file is as simple as this:</p>
  <pre><code>@SpringBootApplication
  class PackitApplication
  
  fun main(args: Array&lt;String&gt;) {
      runApplication&lt;PackitApplication&gt;(*args)
  }
  </code></pre>
  <p>Does someone know what I'm missing? This is the first project on spring I'm trying to deploy on heroku, so please bare with me.</p>
  <p>Thank you in advance.</p>