no main manifest attribute, in helloworld.jar - absolute beginner

已回答

I hope you don't mind me posting here. I'm absolutely new to both Kotlin and modern IDEs & programming  (the tiny amount of programming I learnt was BASIC back in the 80s and 90s).

I've been slowly working through the basic Kotlin course on Hyperskills (just a few days in) and tinkering with what I've learnt in Kotlin Playground.

Rather rashly I thought I'd have a play in intellj IDEA and started with the standard Hello World program. I can build and run it in intellj IDEA but thought I'd be clever I try and run it in a Windows Powershell window. Thanks to the web I managed to compile a .jar file but when I run it  (java -jar helloworld.jar) it generates an error "no main manifest attribute, in helloworld.jar".

Is there a simple way to resolve this (I understand virtually nothing of what's going on behind the scenes) or am I trying to run before I can walk and better off just following the course?

评论操作 固定链接
Hi,

You may use the wrong steps/configuration to generate the jar which doesn't include a correct `META-INF/MANIFEST.MF` in the jar indicating the main method entry.
Please try the guide here to see if it helps: https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Kotlin#package-as-jar
0
评论操作 固定链接

Thank you for taking the time to help a beginner and providing a link to the instructions.

As someone who's new to all this and more than a little bemused, I'd stuck to the default settings when creating my Hello World program, which meant that intellij was selected as the build system; should I be looking at building with Gradle or will the intellij system be sufficient for a beginner?

It turns out that the instructions I was following where the Jet Brains one you pointed to, but for the intellij system. I've had a quick look at the Gradle approach, but rather than confuse myself with more new stuff, I had another go with the intellij approach.

In the meantime I'd updated my Java installation and installed the 64bit package; the SDK on the new project requester had changed from openjdk1.8 to 1.9. This time when I compiled the .jar file it ran correctly!

Thank you again for helping out, do you think I should use Gradle in place of the default Intellij build system?

0
评论操作 固定链接
The IntelliJ system would be sufficient for you.
But if you need to add some dependencies to this project, manage these dependencies, or need some other features (like building projects from the command line), the Gradle/Maven build subsystem would be better.

Should you have any questions, please don't hesitate to ask.
0

请先登录再写评论。