Hi, I am learning to code apps using Kotlin.
In order to learn Kotlin, I am trying to build console apps and desktop apps.
So far, I can run my hello world apps using gradlew run
(or from the IDE).
However, I cannot seem to be able to build a .jar file which is runnable using:
kotlin App.jar
or
java - jar App.jar
PS: I am new with Kotlin, but I am familiar with most of the build tools from all the languages in the top 10 of the TIOBE index.
- One thing that puzzles me is why the default app generated by
Gradle init
or IntelliJ seems to come without a manifest file. - Another thing which I am unsure of is the actual qualified name of the main class : Is it āMainKtā or "projectName.Mainkt"or āorg.example.MainKtā or something else (the build.gradel.kts file points to āMainKtā it seems).
- When using the menu command: File->Project structure to add āArtifactsā, the main class is not detected by the dialog box.
- When I edit a manifest file containing the following:
Manifest-Version: 1.0
Main-Class: MainKt
the class name MainKt is highlighted in red (with the hint: Cannot resolve class āMainKtā).
I am using:
- Java :
openjdk version "18.0.1.1" 2022-04-22
- Kotlin:
openjdk version "18.0.1.1" 2022-04-22
- Gradle:
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1.1 (Homebrew 18.0.1.1+0)
OS: Mac OS X 12.4 aarch64
- IntelliJ:
IntelliJ IDEA 2022.1.2 (Community Edition)
Build #IC-221.5787.30, built on May 31, 2022
Runtime version: 11.0.15+10-b2043.56 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.4
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Non-Bundled Plugins:
org.jetbrains.kotlin (221-1.7.0-release-281-IJ5591.52)
org.jetbrains.kotlin-js-inspection-pack-plugin (0.0.9)
Kotlin: 221-1.7.0-release-281-IJ5591.52