This may seem like a obvious question, yet after an hour of trying to fix it and a few hours before that last week I still can't figure it out. It seems like nowhere there are actually tutorials trying to create a jar file with a Kotlin-file as main class. I believe this must be possible.
I was especially surprised since most java-related builds were relatively self-explanatory on Idea, this is the first time I get issues while building.
I can't share the full project so I'm going to be as specific as I can.
I have a mixed Java/Kotlin project, with a Gradle build set up, as well as some dependencies in Maven.
When I try to make a JAR out of it I do the following:
- In 'Project Structure', click Add > Jar > From Modules with Dependencies, then click the 3 dots next to main class and select your kotlin file (that has a main function)
- Click ok and let idea make your manifest file.
- Then do Build > Build Artifacts and select your Jar artifact.
For me, now 2 things happen:
1. The META-INF is overwritten by one of the dependencie's version (Jackson)
Here is the first few rows of the manifest file now residing in META-INF/
2. When I force my own manifest into the jar, I get this error:
➜ jar git:(master) ✗ java -jar 'test.jar'
Error: Could not find or load main class com.test.main.MainKt
I've been trying to fix this a long time, thanks in advance!